**************************************************
*Do-file:
*It's the robots, stupid? Automation Risk, Labour Market Resources and Incumbent Support in Europe
*Research and Politics
*Set-up file

*Janaury 11th 2024*


****************************************************
*********************** 1. Set-up *******************
*****************************************************

/*cd "set working directory"*/
*/ I import the data for waves 1-8 
*/ I subsequently append with wave 9 (leaving us with 366k obs.)
use "ESS1-8e01.dta", clear
append using  "ESS/ESS9e03.dta"

drop cname-name
egen Year =rowtotal(inwyys)

*/ I code years and country dummies for simplicy and to facilitate a subsequent merge
gen year = .
replace year = 2002 if essround == 1
replace year = 2004 if essround == 2
replace year = 2006 if essround == 3
replace year = 2008 if essround == 4
replace year = 2010 if essround == 5
replace year = 2012 if essround == 6
replace year = 2014 if essround == 7
replace year = 2016 if essround == 8
replace year = 2018 if essround == 9

drop if cntry == "CY"
drop if cntry == "LT"
drop if cntry == "HR"
*/drops 20k obs.


*/recoding regions to merge
{
rename region dregion
gen region =.
encode cregion, gen(nuts)
encode dregion, gen(nuts2)

*Austria
*/NUTS2
replace region = 32 if nuts == 2 | nuts2 == 2  | regionat == 1 //Burgenland
replace region = 171 if nuts == 3 | nuts2 == 3 | regionat == 3 //Lower Austria
replace region = 313 if nuts == 4 | nuts2 == 4 | regionat == 9 //Vienna
replace region = 123 if nuts == 5 | nuts2 == 5 | regionat == 2 // Karten
replace region = 123 if nuts == 5 | nuts2 == 5 | regionat == 2 // Karten
replace region = 264 if nuts == 6 | nuts2 == 6 | regionat == 6 // Styria
replace region = 201 if nuts == 7 | nuts2 == 7 | regionat == 4 //Oberostenreich
replace region = 247 if nuts == 8 | nuts2 == 8 | regionat == 5 //Salzbur
replace region = 283 if nuts == 9 | nuts2 == 9 | regionat == 7 //Tirol
replace region = 295 if nuts == 10 | nuts2 == 10 | regionat == 8 //Voralberg

*Belgium
*/NUTS1 2002-2012
*/NUTS2 2012-

replace region = 294 if regionbe == 1 //Flanders
replace region = 242 if regionbe == 2 //Brussels
replace region = 243 if regionbe == 3 //Wallonia

replace region = 242 if nuts == 11 | nuts2 == 11 //Brussels
replace region = 222 if nuts == 12 | nuts2 == 12 //Antwerp
replace region = 225 if nuts == 13 | nuts2 == 13 //Limburg
replace region = 229 if nuts == 14 | nuts2 == 14 //East Flanders
replace region = 230 if nuts == 15 | nuts2 == 15 //Flemish Brabant
replace region = 241 if nuts == 16 | nuts2 == 16 //West Flanders
replace region = 223 if nuts == 17 | nuts2 == 17 //Walloon Brabant
replace region = 224 if nuts == 18 | nuts2 == 18 //Hainaut
replace region = 226 if nuts == 19 | nuts2 == 19 //Liege
replace region = 227 if nuts == 20 | nuts2 == 20 //Luxembourg
replace region = 228 if nuts == 21 | nuts2 == 21 //Namur

*Czechia
*/NUTS2
replace region = 220 if nuts == 29 | nuts2 == 57 | regioncz == 1 //Praha
replace region = 268 if nuts == 30 | nuts2 == 58 | regioncz == 2 //Stredni Cechy
replace region = 113 if nuts == 31 | nuts2 == 59 | regioncz == 3 //Jihozapad
replace region = 113 if nuts == 32 | nuts2 == 60 | regioncz == 3 //Jihozapad
replace region = 353 if nuts == 33 | nuts2 == 61 | regioncz == 4 //Severozapad
replace region = 253 if nuts == 34 | nuts2 == 62 | regioncz == 4 //Severozapad
replace region = 252 if nuts == 35 | nuts2 == 63 | regioncz == 5 //Severovychod
replace region = 252 if nuts == 36 | nuts2 == 64 | regioncz == 5 //Severovychod
replace region = 252 if nuts == 37 | nuts2 == 65 | regioncz == 5 //Severovychod
replace region = 112 if nuts == 38 | nuts2 == 66 | regioncz == 6 //Jihovychod
replace region = 112 if nuts == 39 | nuts2 == 67 | regioncz == 6 //Jihovychod
replace region = 269 if nuts == 40 | nuts2 == 68 | regioncz == 7 //Stredni Morava
replace region = 269 if nuts == 41 | nuts2 == 79 | regioncz == 7 //Stredni Morava
replace region = 167 if nuts == 42 | nuts2 == 70 | regioncz == 8 //Moravskoslezsko


*Germany
*/NUTS1
replace region = 17  if nuts == 43 | nuts2 == 71 | regionde == 8  //Baden-Wurttemberg
replace region = 20  if nuts == 44 | nuts2 == 72 | regionde == 9  //Bayern
replace region = 23  if nuts == 45 | nuts2 == 73 | regionde == 11 //Berlin
replace region = 26  if nuts == 46 | nuts2 == 74 | regionde == 12 //Brandenburg
replace region = 29  if nuts == 47 | nuts2 == 75 | regionde == 4  //Bremen
replace region = 96  if nuts == 48 | nuts2 == 76 | regionde == 2  //Hamburg
replace region = 103 if nuts == 49 | nuts2 == 77 | regionde == 6  //Hessen
replace region = 160 if nuts == 50 | nuts2 == 78 | regionde == 13 //Mecklenburg-Vorpommern
replace region = 170 if nuts == 51 | nuts2 == 79 | regionde == 3  //Niedersachsen
replace region = 182 if nuts == 52 | nuts2 == 80 | regionde == 5  //Nordrhein-Westfalen
replace region = 240 if nuts == 53 | nuts2 == 81 | regionde == 7  //Rheinland-Pfalz
replace region = 244 if nuts == 54 | nuts2 == 82 | regionde == 10 //Saarland
replace region = 245 if nuts == 55 | nuts2 == 83 | regionde == 14 //Sachsen
replace region = 246 if nuts == 56 | nuts2 == 84 | regionde == 15 //Sachsen-Anhalt
replace region = 249 if nuts == 57 | nuts2 == 85 | regionde == 1  //Schleszig-Holstein
replace region = 282 if nuts == 58 | nuts2 == 86 | regionde == 16 //Thuringen

*Denmark
*/NUTS2
replace region = 105 if nuts == 59 | nuts2 == 87 | regiondk == 1 //Hovedstaden
replace region = 256 if nuts == 60 | nuts2 == 88 | regiondk == 2 //Sjaelland
replace region = 275 if nuts == 61 | nuts2 == 89 | regiondk == 3 //Syddanmarken
replace region = 164 if nuts == 62 | nuts2 == 90 | regiondk == 4 //Midtjylland
replace region = 181 if nuts == 63 | nuts2 == 91 | regiondk == 5 //Nordtjylland

*Estonia
*/NUTS0
replace region = 80 if nuts == 64 |  nuts2 == 92 | regionee == 1 //Põhja-Eesti
replace region = 80 if nuts == 65 |  nuts2 == 93 | regionee == 4 //Lääne-Eesti 
replace region = 80 if nuts == 66 |  nuts2 == 94 | regionee == 6 //Kesk-Eesti
replace region = 80 if nuts == 67 |  nuts2 == 95 | regionee == 7 //Kirde-Eesti
replace region = 80 if nuts == 68 |  nuts2 == 96 | regionee == 8 //Lõuna-Eesti

*Spain
*/NUTS2
replace region = 88 if nuts == 69  |  nuts2 == 97 | regiones == 11 //Galicia
replace region = 221 if nuts == 70 |  nuts2 == 98 |regiones == 12 //Asturia
replace region = 36 if nuts == 71  |  nuts2 == 99 |regiones == 13 //Cantabria
replace region = 210 if nuts == 72 |  nuts2 == 100 | regiones == 21 //Basque Community
replace region = 49 if nuts == 73  |  nuts2 == 101 | regiones == 22 //Navarre
replace region = 127 if nuts == 74 |  nuts2 == 102 | regiones == 23 //La Rioja
replace region = 12 if nuts == 75  |  nuts2 == 103 | regiones == 24 //Aragon 
replace region = 51 if nuts == 76  |  nuts2 == 105 | regiones == 30 //Madrid
replace region = 37 if nuts == 77  |  nuts2 == 104 | regiones == 41 //Castille-Leon
replace region = 38 if nuts == 78  |  nuts2 == 106 | regiones == 42 //Castilla-La Mancha
replace region = 82 if nuts == 79  |  nuts2 == 107 | regiones == 43 //Extramadura
replace region = 39 if nuts == 80  |  nuts2 == 108 | regiones == 51 //Catalonia
replace region = 50 if nuts == 81  |  nuts2 == 109 | regiones == 52 //Valencian Community
replace region = 108 if nuts == 82 |  nuts2 == 110 | regiones == 53 //Balearic Islands
replace region = 9 if nuts == 83   |  nuts2 == 111 | regiones == 61 //Andalusia
replace region = 238 if nuts == 84 |  nuts2 == 112 | regiones == 62 //Region of Murcia
replace region = 47 if nuts == 85  |  nuts2 == 113 | regiones == 63 //Ceuta 
replace region = 48 if nuts == 86  |  nuts2 == 114 | regiones == 63 //Melilla
replace region = 35 if nuts == 87  |  nuts2 == 115 | regiones == 70 //Canary Islands


*Finland
*/NUTS2
replace region = 332 if nuts == 120 | nuts2 == 134 | regionfi == 2 //Aland
replace region = 217 if nuts == 88  | nuts2 == 127 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 89  | nuts2 == 128 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 90  | nuts2 == 130 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 91  | nuts2 == 131 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 113 | nuts2 == 132 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 114 | nuts2 == 133 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 115 | nuts2 == 127 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 116 | nuts2 == 128 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 117 | nuts2 == 129 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 118 | nuts2 == 130 | regionfi == 3 //Pohjois-Suomi
replace region = 217 if nuts == 119 | nuts2 == 131 | regionfi == 3 //Pohjois-Suomi
replace region = 81 if nuts == 92   | nuts2 == 122 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 93   | nuts2 == 123 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 94   | nuts2 == 124 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 95   | nuts2 == 125 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 96   | nuts2 == 126 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 97   | nuts2 == 122 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 98   | nuts2 == 123 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 108  | nuts2 == 124 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 109  | nuts2 == 125 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 110  | nuts2 == 126 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 111  | nuts2 == 122 | regionfi == 2 //Etela-Suomi
replace region = 81 if nuts == 112  | nuts2 == 123 | regionfi == 2 //Etela-Suomi
replace region = 101 if nuts == 93  | nuts2 == 121 | regionfi == 1 //Helsinki
replace region = 101 if nuts == 107 | nuts2 == 121 | regionfi == 1 //Helsinki
replace region = 144 if nuts == 99  | nuts2 == 116 | regionfi == 4 //Lans-Suomi
replace region = 144 if nuts == 100 | nuts2 == 116 | regionfi == 4 //Lans-Suomi
replace region = 144 if nuts == 103 | nuts2 == 117 | regionfi == 4 //Lans-Suomi
replace region = 144 if nuts == 104 | nuts2 == 118 | regionfi == 4 //Lans-Suomi
replace region = 144 if nuts == 105 | nuts2 == 119 | regionfi == 4 //Lans-Suomi
replace region = 144 if nuts == 106 | nuts2 == 120 | regionfi == 4 //Lans-Suomi

*France
*/NUTS2
replace region = 326 if nuts == 121| nuts2 == 135 | regionfr == 1 //Ile De rance
replace region = 44 if nuts == 122 | nuts == 150 | nuts2 == 144 |  regionfr == 2 //Champagne-Ardenne
replace region = 213 if nuts == 123| nuts == 148 | nuts2 == 142 | regionfr == 2 //Picardie
replace region = 99 if nuts == 124 | nuts == 146 | nuts2 == 140 | regionfr == 3 //Haute-Normandie
replace region = 40 if nuts == 125 | nuts == 142 | nuts2 == 136 | regionfr == 5 //Centre
replace region = 19 if nuts == 126 | nuts == 145 | nuts2 == 139 | regionfr == 3 //Basse-Normandie
replace region = 24 if nuts == 127 | nuts == 143 | nuts2 == 137 | regionfr == 2 //Bourgogne
replace region = 179 if nuts == 128| nuts == 147 | nuts2 == 141 | regionfr == 4 //Nord-Pas-De-Calais
replace region = 141 if nuts == 129| nuts == 151 | nuts2 == 145 | regionfr == 5 //Lorraine
replace region = 6 if nuts == 130  | nuts == 149 | nuts2 == 143 | regionfr == 5 //Alsace
replace region = 84 if nuts == 131 | nuts == 144 | nuts2 == 138 | regionfr == 5 //Franche-Comte
replace region = 209 if nuts == 132| nuts == 152 | nuts2 == 146 | regionfr == 6 //Pays De La Loire
replace region = 30 if nuts == 133 | nuts == 153 | nuts2 == 147 | regionfr == 6 //Bretagne
replace region = 218 if nuts == 134| nuts == 156 | nuts2 == 150 | regionfr == 6 //Poitou-Charentes
replace region = 10 if nuts == 135 | nuts == 154 | nuts2 == 148 | regionfr == 7 //Aquitaine
replace region = 163 if nuts == 136| nuts == 158 | nuts2 == 152 | regionfr == 7 //Midi-Pyrenees
replace region = 137 if nuts == 137| nuts == 155 | nuts2 == 149 | regionfr == 7 //Limousin
replace region = 241 if nuts == 138| nuts == 160 | nuts2 == 154 | regionfr == 8 //Rhone-Alpes
replace region = 15 if nuts == 139 | nuts == 159 | nuts2 == 153 | regionfr == 8 //Auvergne
replace region = 130 if nuts == 140| nuts == 157 | nuts2 == 151 | regionfr == 9 //Longuedoc-Roussillon

*Greece
*/NUTS2
replace region = 8 if nuts == 162   | regiongr == 11 //Anatoliki Makedonia, Thraki
replace region = 118 if nuts == 163 | regiongr == 12 //Kentriki Makedonia
replace region = 66 if nuts == 164  | regiongr == 13 //Dytiki Makedonia
replace region = 281 if nuts == 165 | regiongr == 12 //Thessalia
replace region = 110 if nuts == 166 | regiongr == 21 //Ipeiros
replace region = 109 if nuts == 167 | regiongr == 22 //Ionia Nisia
replace region = 65  if nuts == 168 | regiongr == 23 //Dytiki Ellada
replace region = 265 if nuts == 169 | regiongr == 24 //Sterea Ellada
replace region = 211 if nuts == 170 | regiongr == 25 //Peloponnisos
replace region = 14 if nuts == 171  | regiongr == 3 //Attiki
replace region = 297 if nuts == 172 | regiongr == 41 //Vareia Aigaio
replace region = 196 if nuts == 173 | regiongr == 42 //Notio Aigaio
replace region = 120 if nuts == 174 | regiongr == 43 //Kriti

*Hungary
*/NUTS2
replace region = 31 if nuts == 175  | nuts2 == 156  | regionhu == 1  //Budapest
replace region = 212 if nuts == 176 | nuts2 == 157  | regionhu == 1  //Pest
replace region = 125 if nuts == 177 | nuts == 178 | nuts == 179 | nuts2 == 158  | nuts2 == 159  | nuts2 == 160  | regionhu == 2  //Kozep-Duntanul
replace region = 197 if nuts == 180 | nuts == 181 | nuts == 182 | nuts2 == 161  | nuts2 == 162  | nuts2 == 163  |  regionhu == 3  //Nyugat-Duntanul
replace region = 68  if nuts == 183 | nuts == 184 | nuts == 185 | nuts2 == 164  | nuts2 == 165  | nuts2 == 166  | regionhu == 4  //Del-Duntanul
replace region = 324 if nuts == 186 | nuts == 187 | nuts == 188 | nuts2 == 167  | nuts2 == 168  | nuts2 == 169  | regionhu == 5  //Eszak-Magyarorszag
replace region = 323 if nuts == 189 | nuts == 190 | nuts == 191 | nuts2 == 170  | nuts2 == 171  | nuts2 == 172  | regionhu == 6  //Eszak-Alfold
replace region = 67  if nuts == 192 | nuts == 193 | nuts == 194 | nuts2 == 173  | nuts2 == 174  | nuts2 == 175  | regionhu == 7  //Del-Alfold

*Ireland
*/NUTS2
replace region = 194 if nuts == 195 | nuts == 196 | nuts == 197 | nuts2 == 176 | nuts2 == 177 |regionie == 1 | regionie == 2 | regionie == 3 //Northern and Western
replace region = 76  if nuts == 198 | nuts == 199 | nuts2 == 181 | nuts2 == 181 | nuts2 == 183 | regionie == 4 | regionie == 5  //Eastern and Midlands
replace region = 262 if nuts == 200 | nuts == 201 | nuts == 202 | nuts2 == 178 | nuts2 == 179 | nuts2 == 180 | regionie == 6 | regionie == 7 | regionie == 8  //Southern

*Italy
*/NUTS2
replace region = 214 if nuts == 203 | regionie == 1 //Piemonte
replace region = 291 if nuts == 204 | regionie == 2 //Valle d'Osta
replace region = 135 if nuts == 205 | nuts2 == 186 | regionie == 7 //Liguria
replace region = 139 if nuts == 206 | regionie == 3 //Lombardia
replace region = 1   if nuts == 207 | regionie == 13 | regionie == 14 //Abruzzo (+Molise)
replace region = 34  if nuts == 208 | regionie == 15 //Campagnia
replace region = 235 if nuts == 209 | nuts2 == 187 | regionie == 16 //Puglia
replace region = 18  if nuts == 210 | regionie == 17 //Basilicata
replace region = 33  if nuts == 211 | regionie == 18 //Calabria
replace region = 255 if nuts == 212 | nuts2 == 188 |  regionie == 19 //Sicilia
replace region = 248 if nuts == 213 | regionie == 20 //Sardagna
replace region = 233 if nuts == 214 | regionie == 4 //Trentino/Sudtirol
replace region = 234 if nuts == 215 | regionie == 4 //Trentino/Sudtirol
replace region = 292 if nuts == 216 | nuts2 == 189 | regionie == 5 //Veneto
replace region = 87  if nuts == 217 | regionie == 6 //Friuli-Venezia Giulia
replace region = 77  if nuts == 218 | regionie == 8 //Emilia-Romagna
replace region = 284 if nuts == 219 | regionie == 9 //Toscana
replace region = 288 if nuts == 220 | nuts2 == 190 | regionie == 10 //Umbria
replace region = 156 if nuts == 221 | regionie == 11 //Marche
replace region = 132 if nuts == 222 | regionie == 12 //Lazio


*Netherlands
*/NUTS2
replace region = 93 if nuts == 223   | nuts2 == 198 |    regionnl == 111 | regionnl == 112 | regionnl == 113 //Groningen
replace region = 86 if nuts == 224   | nuts2 == 199 |  regionnl == 121 | regionnl == 122 | regionnl == 123 //Friesland
replace region = 62 if nuts == 225   | nuts2 == 200 |  regionnl == 131 | regionnl == 132 | regionnl == 133 //Drenthe
replace region = 208 if nuts == 226  | nuts2 == 201 |  regionnl == 211 | regionnl == 212 | regionnl == 213 //Overijssel
replace region = 89 if nuts == 227   | nuts2 == 202 |  regionnl == 221 | regionnl == 222 | regionnl == 223 | regionnl == 224 //Gelderland
replace region = 83 if nuts == 228   | nuts2 == 203 |  regionnl == 230 //Flevoland
replace region = 290 if nuts == 229  | nuts2 == 204 |  regionnl == 310 //Utrecht
replace region = 174 if nuts == 230  | nuts2 == 205 |  regionnl == 321 | regionnl == 322 | regionnl == 323 | regionnl == 324 | regionnl == 325 | regionnl == 326 | regionnl == 327 //Noord-Holland
replace region = 318 if nuts == 231  | nuts2 == 206 |  regionnl == 331 | regionnl == 332 | regionnl == 333 | regionnl == 334 | regionnl == 335 | regionnl == 336 | regionnl == 337 //Zuid-Holland
replace region = 317 if nuts == 232  | nuts2 == 207 |  regionnl == 341 | regionnl == 342 //Zeeland
replace region = 173 if nuts == 233  | nuts2 == 208 |  regionnl == 411 | regionnl == 412 | regionnl == 413 | regionnl == 414 //Noord-Brabant
replace region = 136 if nuts == 234  | nuts2 == 209 |  regionnl == 421 | regionnl == 422 | regionnl == 423 //Limburg

*Poland
*/NUTS2
replace region = 145 if nuts == 242 | nuts2 == 217 | regionpl == 10  //Lodzkie
replace region = 159 if nuts == 243 | nuts2 == 218 | regionpl == 14 //Mazowieckie
replace region = 154 if nuts == 244 | nuts2 == 219 | regionpl == 12 //Małopolskie	
replace region = 257 if nuts == 245 | nuts2 == 220 | regionpl == 24  //Śląskie
replace region = 142 if nuts == 246 | nuts2 == 221 | regionpl == 6  //Lubelskie	
replace region = 215 if nuts == 247 | nuts2 == 222 | regionpl == 18  //Podkarpackie	
replace region = 274 if nuts == 248 | nuts2 == 223 | regionpl == 26  //Świętokrzyskie
replace region = 216 if nuts == 249 | nuts2 == 224 | regionpl == 20  //Podlaskie
replace region = 312 if nuts == 250 | nuts2 == 225 | regionpl == 40  //Wielkopolskie
replace region = 315 if nuts == 251 | nuts2 == 226 | regionpl == 32  //Zachodniopomorskie
replace region = 143 if nuts == 252 | nuts2 == 227 | regionpl == 8  //Lubuskie
replace region = 60  if nuts == 253 | nuts2 == 228 | regionpl == 2  //Dolnośląskie
replace region = 203 if nuts == 254 | nuts2 == 229 | regionpl == 16  //Opolskie
replace region = 121 if nuts == 255 | nuts2 == 230 | regionpl == 4  //Kujawsko-Pomorskie
replace region = 301 if nuts == 256 | nuts2 == 231 | regionpl == 28  //Warmińsko-Mazurskie
replace region = 219 if nuts == 257 | nuts2 == 232 | regionpl == 22  //Pomorskie

*Portugal
*/NUTS2
replace region = 188 if nuts == 258 | nuts2 == 233 | regionpt == 1  //Norte
replace region = 5 if nuts == 259   | nuts2 == 234 | regionpt == 5  //Algarve
replace region = 43 if nuts == 260  | nuts2 == 235 | regionpt == 2  //Centro
replace region = 321 if nuts == 261 | nuts2 == 236 | regionpt == 3  //Lisboa
replace region = 3 if nuts == 262   | nuts2 == 237 | regionpt == 4  //Alentejo

*Sweden
*/NUTS2
replace region = 266 if nuts == 263 | nuts2 == 242| regionse == 1  //Stockholm
replace region = 326 if nuts == 264 | nuts == 265 | nuts == 266 | nuts == 267 | nuts == 268 | nuts2 == 243 |regionse == 2  //Ostra Mellansverige
replace region = 258 if nuts == 269 | nuts == 270 | nuts == 271 | nuts2 == 244 | regionse == 7  //Smaland Med Oanna
replace region = 276 if nuts == 272 | nuts == 273 | nuts2 == 245 | regionse == 3 //Sydsverige
replace region = 299 if nuts == 274 | nuts == 275 | nuts2 == 246 | regionse == 8  //Vastsverige
replace region = 186 if nuts == 276 | nuts == 277 | nuts2 == 247 | nuts == 278 | regionse == 4 //Norra Mellansverige
replace region = 161 if nuts == 279 | nuts == 280 | nuts2 == 248 | nuts == 281 | regionse == 5  //Mellansta Norrland
replace region = 328 if nuts == 282 | nuts == 283 | nuts2 == 249 | regionse == 6  //Ovre Norrland

*Slovenia
*/NUTS2
replace region = 298 if nuts == 284  | nuts == 285 | nuts == 286  | nuts == 287 | nuts == 288 | nuts == 289 | nuts == 290 | nuts == 291 | regionsi == 3 | regionsi == 4 | regionsi == 5 | regionsi == 8 | regionsi == 9 | regionsi == 10 | regionsi == 11 | regionsi == 12 //Vzhodna Slovenija
replace region = 316 if nuts == 292  | nuts == 293 | nuts == 294  | nuts == 295 | regionsi == 1  | regionsi == 2 | regionsi == 6 | regionsi == 7 //Zahodna Slovenija
replace region = 298 if nuts2 == 250 | nuts2 == 251| nuts2 == 252 | nuts2 == 253 | nuts2 == 254 | nuts2 == 255 | nuts2 == 256 | nuts2 == 257 | regionsi == 3 | regionsi == 4 | regionsi == 5 | regionsi == 8 | regionsi == 9 | regionsi == 10 | regionsi == 11 | regionsi == 12 //Vzhodna Slovenija
replace region = 316 if nuts2 == 258  | nuts2 == 259 | nuts2 == 260  | nuts2 == 261 | regionsi == 1  | regionsi == 2 | regionsi == 6 | regionsi == 7 //Zahodna Slovenija


*Slovakia
*/NUTS2
replace region = 27  if nuts == 296 | nuts2 == 262 | regionsk == 1  //Bratislava
replace region = 320 if nuts == 297 | nuts == 298 | nuts == 299 | nuts2 == 263 | nuts2 == 264 | nuts2 == 265 | regionsk == 2 |  regionsk == 3 |  regionsk == 4  //Západné Slovensko
replace region = 267 if nuts == 300 | nuts == 301 | nuts2 == 266 | nuts2 == 267 |regionsk == 5 |  regionsk == 6  //Stredné Slovensko
replace region = 300 if nuts == 302 | nuts == 303 | nuts2 == 268 | nuts2 == 269 |regionsk == 7 |  regionsk == 8  //Východné Slovensk

*United Kingdom
*/NUTS1
replace region = 189 if nuts == 304  | nuts2 == 270 | regiongb == 1  //North East
replace region = 191 if nuts == 305  | nuts2 == 271 | regiongb == 2  //North West
replace region = 309 if nuts == 306  | nuts2 == 272 | regiongb == 3  //North Yorkshire & the Humber
replace region = 71  if nuts == 307  | nuts2 == 273 | regiongb == 4  //East Midlands
replace region = 307 if nuts == 308  | nuts2 == 274 | regiongb == 5  //West Midlands
replace region = 74  if nuts == 309  | nuts2 == 275 | regiongb == 7  //East of England
replace region = 140 if nuts == 310  | nuts2 == 276 | regiongb == 8  //London
replace region = 259 if nuts == 311  | nuts2 == 277 | regiongb == 9  //South East
replace region = 260 if nuts == 312  | nuts2 == 278 | regiongb == 6  //South West
replace region = 301 if nuts == 313  | nuts2 == 279 | regiongb == 10  //Wales
replace region = 251 if nuts == 314  | nuts2 == 280 | regiongb == 11  //Scotland
replace region = 193 if nuts == 315  | nuts2 == 281 | regiongb == 12  //Northern Ireland

}
 
merge m:1 region year using "Regional11-9.dta",
drop _merge


drop if inlist(cntry,"LV")
drop if inlist(cntry,"NO")
drop if inlist(cntry,"ME")
drop if inlist(cntry,"CH")
drop if inlist(cntry,"RS")
drop if inlist(cntry,"BG")
drop if inlist(cntry,"IS")


encode cntry, gen(cntry2)
drop country
gen country=.
replace country = 1 if cntry2 == 1
replace country = 2 if cntry2 == 2
replace country = 3 if cntry2 == 3
replace country = 4 if cntry2 == 5
replace country = 5 if cntry2 == 6
replace country = 6 if cntry2 == 8
replace country = 7 if cntry2 == 9
replace country = 8 if cntry2 == 4
replace country = 9 if cntry2 == 11
replace country = 10 if cntry2 == 12
replace country = 11 if cntry2 == 13
replace country = 12 if cntry2 == 14
replace country = 13 if cntry2 == 15
replace country = 14 if cntry2 == 16
replace country = 15 if cntry2 == 17
replace country = 16 if cntry2 == 20
replace country = 17 if cntry2 == 19
replace country = 18 if cntry2 == 7
replace country = 19 if cntry2 == 18
replace country = 20 if cntry2 == 10


gen west =0
replace west = 1 if country == 1
replace west = 1 if country == 2
replace west = 1 if country == 4
replace west = 1 if country == 6
replace west = 1 if country == 7
replace west = 1 if country == 8
replace west = 1 if country == 9
replace west = 1 if country == 11
replace west = 1 if country == 12
replace west = 1 if country == 13
replace west = 1 if country == 15
replace west = 1 if country == 18
replace west = 1 if country == 19
replace west = 1 if country == 20

label define country 1 "Austria" 2 "Belgium" 3 "Czech Republic"  4 "Denmark" 5 "Estonia" 6 "Finland"  7 "France" ///
8 "Germany" 9 "Greece" 10 "Hungary" 11 "Ireland" 12 "Italy" 13 "Netherlands" 14 "Poland" ///
15 "Portugal" 16 "Slovakia" 17 "Slovenia" 18 "Spain" 19 "Sweden" 20 "United Kingdom"

gen farrightcountries = 0
replace farrightcountries =1 if country == 1 
replace farrightcountries =1 if country == 2
replace farrightcountries =1 if country == 3
replace farrightcountries =1 if country == 4
replace farrightcountries =1 if country == 5
replace farrightcountries =1 if country == 6
replace farrightcountries =1 if country == 7
replace farrightcountries =1 if country == 8
replace farrightcountries =1 if country == 9
replace farrightcountries =1 if country == 10
replace farrightcountries =1 if country == 12
replace farrightcountries =1 if country == 13
replace farrightcountries =1 if country == 14
replace farrightcountries =1 if country == 16
replace farrightcountries =1 if country == 17
replace farrightcountries =1 if country == 19

label values country country

*********************** Final merges ********************
*/ I merge the ESS data with economic and institutional peripherals
merge m:1 year country using  "econ.dta"

drop if _merge == 1
drop if _merge == 2
drop _merge

*/ I merge in Jahn's corporatism index
merge m:1 year country using  "Jahnindex.dta"

gen jahn = corporatism_z37
drop if _merge == 1
drop if _merge == 2
drop _merge

*/ I merge in Arntz (https://wecglobal.org/uploads/2019/07/2016_OECD_Risk-Automation-Jobs.pdf)
merge m:1 essround isco08 country using   "Arntz.dta"
drop _merge

*/ I merge fiscal data from Eurostat
merge m:1 year country using  "spending.dta"
drop _merge


********************************************************************
*********************** 5. Party choice and position ***************
********************************************************************
*/ here I transform reported party choice in elections into ideological positions
*/ I use the Chapel Hill Expert Survey (CHES) 
*/ All parties are scored on a:
*/ a. incumbent or not (1 - 0)
*/ b. Left-Right scale (0-10)
*/ c. GAL-TAN scale (0-10)
*/ d Anti-elite salience (0-10) - only after 2014
*/ Extreme parties are coded as either radical left or radical right using the CHES party family information


*/dummies for non-voting and non-responses
gen refusalvote = 0
foreach var of varlist prtvtat-prtvtcua {
replace refusalvote = 1 if `var' == .b
}
gen unknownvote = 0
foreach var of varlist prtvtat-prtvtcua {
replace unknownvote = 1 if `var' == .c
replace unknownvote = 1 if `var' == .d
}

gen LR = 0
gen galtan = 0
gen rleft = 0
gen rright = 0
gen cleft = 0
gen cright =0
gen election = 0
gen pmleft=0
gen pmright=0
gen pmrleft=0
gen pmrright=0
gen incumbent=0
replace rleft = 0 if refusalvote == 0
replace rleft = 0 if unknownvote == 0
replace rright = 0 if refusalvote == 0
replace rright = 0 if unknownvote == 0
replace cleft = 0 if refusalvote == 0
replace cleft = 0 if unknownvote == 0
replace cright = 0 if refusalvote == 0
replace cright = 0 if unknownvote == 0
gen antielite = .


{
***** Austria *****
* 2006 - 2014
replace LR = 2.83 if prtvtaat == 1
replace galtan = 3.5 if prtvtaat == 1
replace LR = 6.83 if prtvtaat == 2
replace galtan = 7.67 if prtvtaat == 2
replace LR = 4.83 if prtvtaat == 3
replace galtan = 9.67 if prtvtaat == 3
replace LR = 6 if prtvtaat == 4
replace galtan = 8.83 if prtvtaat == 4
replace LR = 2.6 if prtvtaat == 5
replace galtan = 0.83 if prtvtaat == 5
replace LR = 7.5 if prtvtaat == 6
replace galtan = 1.4 if prtvtaat == 6

replace cleft = 1 if prtvtaat == 1
replace cleft = 1 if prtvtaat == 5
replace cright = 1 if prtvtaat == 2
replace cright = 1 if prtvtaat == 6
replace rright = 1 if prtvtaat == 3
replace rright = 1 if prtvtaat == 4
replace rleft = 1 if prtvtaat == 7

replace antielite = 2.3 if prtvtaat == 1
replace antielite = 1.6 if prtvtaat == 2
replace antielite = 8 if prtvtaat == 3
replace antielite = 6.8 if prtvtaat == 4
replace antielite = 4.8 if prtvtaat == 5

*/ SPO FPO coalition
replace incumbent = 1 if prtvtaat == 1 
replace incumbent = 1 if prtvtaat == 2 
replace election = 1 if country == 1 & year == 2012
replace pmleft =1 if country == 1 & year == 2012

* 2014-2016
replace LR = 2.7 if prtvtbat == 1
replace galtan = 4 if prtvtbat == 1
replace LR = 6.4 if prtvtbat == 2
replace galtan = 7.19 if prtvtbat == 2
replace LR = 5.5 if prtvtbat == 3
replace galtan = 8.8 if prtvtbat == 3
replace LR = 7.19 if prtvtbat == 4
replace galtan = 7.19 if prtvtbat == 4
replace LR = 2.79 if prtvtbat == 5
replace galtan = 1.7 if prtvtbat == 5
replace LR = 7.59 if prtvtbat == 7
replace galtan = 2.9 if prtvtbat == 7
replace LR = 7.9 if prtvtbat == 9
replace galtan = 7.19 if prtvtbat == 9

replace antielite = 2.3 if prtvtbat == 1
replace antielite = 1.6 if prtvtbat == 2
replace antielite = 8 if prtvtbat == 3
replace antielite = 6.8 if prtvtbat == 4
replace antielite = 4.8 if prtvtbat == 5
replace antielite = 6.1 if prtvtbat == 7
replace antielite = 7.9 if prtvtbat == 8

replace cleft = 1 if prtvtbat == 1
replace cleft = 1 if prtvtbat == 5
replace cright = 1 if prtvtbat == 2
replace cright = 1 if prtvtbat == 7
replace rleft = 1 if prtvtbat == 8
replace rright = 1 if prtvtbat == 9
replace rright = 1 if prtvtbat == 3
replace rright = 1 if prtvtbat == 4

*/ SPO FPO coalition
replace incumbent = 1 if prtvtbat == 1
replace incumbent = 1 if prtvtbat == 2
replace election = 2 if country == 1 & year == 2014
replace election = 2 if country == 1 & year == 2016

replace pmleft =1 if country == 1 & year == 2014
replace pmleft =1 if country == 1 & year == 2016

*2018 
replace LR = 2.7 if prtvtcat == 1
replace galtan = 4 if prtvtcat == 1
replace LR = 6.4 if prtvtcat == 2
replace galtan = 7.19 if prtvtcat == 2
replace LR = 5.5 if prtvtcat == 3
replace galtan = 8.8 if prtvtcat == 3
replace LR = 7.19 if prtvtcat == 4
replace galtan = 7.19 if prtvtcat == 4
replace LR = 2.79 if prtvtcat == 5
replace galtan = 1.7 if prtvtcat == 5

replace antielite = 2.3 if prtvtcat == 1
replace antielite = 1.6 if prtvtcat == 2
replace antielite = 8 if prtvtcat == 3
replace antielite = 6.8 if prtvtcat == 4
replace antielite = 4.8 if prtvtcat == 5

replace cleft = 1 if prtvtcat == 1
replace cleft = 1 if prtvtcat == 5
replace cright = 1 if prtvtcat == 2
replace cright = 1 if prtvtcat == 7
replace rleft = 1 if prtvtcat == 8
replace rright = 1 if prtvtcat == 9
replace rright = 1 if prtvtcat == 3
replace cleft = 1 if prtvtcat == 4

*/ OVP FPO coalition
replace incumbent = 1 if prtvtcat == 3
replace incumbent = 1 if prtvtcat == 2 
replace election = 3 if country == 1 & year == 2018
replace pmright =1 if country == 1 & year == 2018



***** Belgium *****
* 2010-2014
*PTB = PVDA Coded
replace LR = 2.3 if prtvtcbe == 1
replace galtan = 1.53 if prtvtcbe == 1
replace LR = 5.4 if prtvtcbe == 2
replace galtan = 6.59 if prtvtcbe== 2
replace LR = 7.8 if prtvtcbe == 3
replace galtan = 7.8 if prtvtcbe== 3
replace LR = 8.8 if prtvtcbe == 4
replace galtan = 5 if prtvtcbe== 4
replace LR = 3.19 if prtvtcbe == 5
replace galtan = 2.9 if prtvtcbe == 5
replace LR = 0.2 if prtvtcbe == 6
replace galtan = 2.27 if prtvtcbe== 6
replace LR = 7.9 if prtvtcbe == 7
replace galtan = 9.6 if prtvtcbe == 7
replace LR =7.6 if prtvtcbe == 8
replace galtan = 3.19 if prtvtcbe == 8
replace LR = 4 if prtvtcbe == 9
replace galtan = 5.28 if prtvtcbe == 9
replace LR = 2.14 if prtvtcbe == 10
replace galtan = 2 if prtvtcbe == 10
replace LR = 8.4 if prtvtcbe == 11
replace galtan = 9.6 if prtvtcbe== 11
replace LR = 7.6 if prtvtcbe == 12
replace galtan = 4.35 if prtvtcbe == 12
replace LR = 2.57 if prtvtcbe == 13
replace galtan = 2.85 if prtvtcbe == 13
replace LR = 0.2 if prtvtcbe == 14
replace galtan = 2.27 if prtvtcbe== 14

replace cright = 1 if prtvtcbe == 2
replace cright = 1 if prtvtcbe == 3
replace cright = 1 if prtvtcbe == 4
replace cright = 1 if prtvtcbe == 8
replace cright = 1 if prtvtcbe == 9
replace cright = 1 if prtvtcbe == 12
replace cleft = 1 if prtvtcbe == 1
replace cright = 1 if prtvtcbe == 5
replace cright = 1 if prtvtcbe == 10
replace cright = 1 if prtvtcbe == 13
replace rright = 1 if prtvtcbe == 7
replace rright = 1 if prtvtcbe == 11
replace rleft = 1 if prtvtcbe == 14
replace rleft = 1 if prtvtcbe == 6

replace antielite = 3 if prtvtcbe == 1
replace antielite = 3 if prtvtcbe == 10
replace antielite = 2 if prtvtcbe == 2
replace antielite = 2 if prtvtcbe == 9
replace antielite = 2.5 if prtvtcbe == 5
replace antielite = 2.5 if prtvtcbe == 13
replace antielite = 9 if prtvtcbe == 7
replace antielite = 1.6 if prtvtcbe == 8
replace antielite = 1.6 if prtvtcbe == 12
replace antielite = 6.1 if prtvtcbe == 3
replace antielite = 8.3 if prtvtcbe == 6
replace antielite = 8.3 if prtvtcbe == 14
replace antielite = 6.5 if prtvtcbe == 15

*/CDNV/CDH, VLD/MR, PS coalition 
replace incumbent = 1 if prtvtcbe == 2 & year == 2012
replace incumbent = 1 if prtvtcbe == 8 & year == 2012
replace incumbent = 1 if prtvtcbe == 9 & year == 2012
replace incumbent = 1 if prtvtcbe == 12 & year == 2012
replace incumbent = 1 if prtvtcbe == 13 & year == 2012

replace election = 1 if country == 2 & year == 2012
replace pmright =1 if country == 2 & year == 2012


*/CDNV/CDH, VLD/MR, PS/SPA coalition 
replace incumbent = 1 if prtvtcbe == 2 & year == 2014
replace incumbent = 1 if prtvtcbe == 5 & year == 2014
replace incumbent = 1 if prtvtcbe == 8 & year == 2014
replace incumbent = 1 if prtvtcbe == 9 & year == 2014
replace incumbent = 1 if prtvtcbe == 12 & year == 2014
replace incumbent = 1 if prtvtcbe == 13 & year == 2014

replace election = 2 if country == 2 & year == 2014
replace pmleft =1 if country == 2 & year == 2014


* 2016-2018
replace LR = 2 if prtvtdbe == 1
replace galtan = 1.2 if prtvtdbe == 1
replace LR = 5.59 if prtvtdbe == 2
replace galtan = 5.59 if prtvtdbe== 2
replace LR = 8.19 if prtvtdbe == 3
replace galtan = 6.19 if prtvtdbe== 3
replace LR = 8.8 if prtvtdbe == 4
replace galtan = 5 if prtvtdbe== 4
replace LR = 2.79 if prtvtcbe == 5
replace galtan = 2.59 if prtvtdbe == 5
replace LR = 0.2 if prtvtdbe == 6
replace galtan = 2.79 if prtvtdbe== 6
replace LR = 5.5 if prtvtdbe == 7
replace galtan = 9 if prtvtdbe == 7
replace LR =7.8 if prtvtdbe == 8
replace galtan = 2.4 if prtvtdbe == 8
replace LR = 4.19 if prtvtdbe == 9
replace galtan = 5 if prtvtdbe == 9
replace LR = 2.2 if prtvtdbe == 10
replace galtan = 1.2 if prtvtdbe == 10
replace LR = 8.4 if prtvtdbe == 11
replace galtan = 9.6 if prtvtdbe== 11
replace LR = 7.5 if prtvtdbe == 12
replace galtan = 3 if prtvtdbe == 12
replace LR = 2.4 if prtvtdbe == 13
replace galtan = 3.4 if prtvtdbe == 13
replace LR = 0.2 if prtvtdbe == 14
replace galtan = 2.27 if prtvtdbe== 14
replace LR = 8.5 if prtvtdbe == 15
replace galtan = 7.5 if prtvtdbe== 15

replace cright = 1 if prtvtdbe == 2
replace cright = 1 if prtvtdbe == 3
replace cright = 1 if prtvtdbe == 4
replace cright = 1 if prtvtdbe == 8
replace cright = 1 if prtvtdbe == 2
replace cright = 1 if prtvtdbe == 9
replace cright = 1 if prtvtdbe == 12
replace cleft = 1 if prtvtdbe == 1
replace cleft = 1 if prtvtdbe == 5
replace cleft = 1 if prtvtdbe == 10
replace cleft = 1 if prtvtdbe == 13
replace rright = 1 if prtvtdbe == 7
replace rright = 1 if prtvtdbe == 11
replace rleft = 1 if prtvtdbe == 14
replace rleft = 1 if prtvtdbe == 6

replace antielite = 3 if prtvtdbe == 1
replace antielite = 3 if prtvtdbe == 10
replace antielite = 2 if prtvtdbe == 2
replace antielite = 2 if prtvtdbe == 9
replace antielite = 2.5 if prtvtdbe == 5
replace antielite = 2.5 if prtvtdbe == 13
replace antielite = 9 if prtvtdbe == 7
replace antielite = 1.6 if prtvtdbe == 8
replace antielite = 1.6 if prtvtdbe == 12
replace antielite = 6.1 if prtvtdbe == 3
replace antielite = 8.3 if prtvtdbe == 6
replace antielite = 8.3 if prtvtdbe == 14
replace antielite = 6.5 if prtvtdbe == 15

*/CDNV/CDH, VLD/MR, PS/SPA coalition 
replace incumbent = 1 if prtvtdbe == 2 
replace incumbent = 1 if prtvtdbe == 5 
replace incumbent = 1 if prtvtdbe == 8
replace incumbent = 1 if prtvtdbe == 9
replace incumbent = 1 if prtvtdbe == 12
replace incumbent = 1 if prtvtdbe == 13

replace election = 2 if country == 2 & year == 2016
replace election = 2 if country == 2 & year == 2018

replace pmleft =1 if country == 2 & year == 2016
replace pmleft =1 if country == 2 & year == 2018



***** Czech Republic *****
*2012 
replace LR = 0.5 if prtvtccz == 1
replace galtan = 5.6 if prtvtccz == 1
replace LR = 2.5 if prtvtccz == 2
replace galtan = 3.57 if prtvtccz == 2
replace LR = 8.3 if prtvtccz == 3
replace galtan = 5.8 if prtvtccz == 3
replace LR = 5.8 if prtvtccz == 4
replace galtan = 4.3 if prtvtccz == 4
replace LR = 8.2 if prtvtccz == 5
replace galtan = 6.1 if prtvtccz == 5

replace rleft = 1 if prtvtccz == 1
replace cleft = 1 if prtvtccz == 2
replace cright = 1 if prtvtccz == 3
replace cright = 1 if prtvtccz == 4
replace cright = 1 if prtvtccz == 5


*/ODS, TOP-VV coalition 
replace incumbent = 1 if prtvtccz == 5 & year == 2012
replace incumbent = 1 if prtvtccz == 2 & year == 2012

replace election = 1 if country == 3 & year == 2012
replace pmright =1 if country == 3 & year == 2012


*2014-2016
replace LR = 1 if prtvtdcz == 1
replace galtan = 6.5 if prtvtdcz == 1
replace LR = 2.7 if prtvtdcz == 2
replace galtan = 4.4 if prtvtdcz == 2
replace LR = 7.8 if prtvtdcz == 3
replace galtan = 5.5 if prtvtdcz == 3
replace LR = 6.3 if prtvtdcz == 4
replace galtan = 3.3 if prtvtdcz == 4
replace LR = 8.1 if prtvtdcz == 5
replace galtan = 6 if prtvtdcz == 5
replace LR = 5.5 if prtvtdcz == 6
replace galtan = 7.6 if prtvtdcz == 6
replace LR = 5.3 if prtvtdcz == 7
replace galtan = 7.7 if prtvtdcz == 7

replace rleft = 1 if prtvtdcz == 1
replace cleft = 1 if prtvtdcz == 2
replace cright = 1 if prtvtdcz == 3
replace cright = 1 if prtvtdcz == 4
replace cright = 1 if prtvtdcz == 5
replace cright = 1 if prtvtdcz == 6
replace rright = 1 if prtvtdcz == 7

replace antielite = 5.8 if prtvtdcz == 1
replace antielite = 1.5 if prtvtdcz == 2
replace antielite = 1.9 if prtvtdcz == 3
replace antielite = 7.7 if prtvtdcz == 4
replace antielite = 2.1 if prtvtdcz == 5
replace antielite = 2.4 if prtvtdcz == 6
replace antielite = 9.4 if prtvtdcz == 7


*/ODS, TOP-VV coalition 
replace incumbent = 1 if prtvtdcz == 5 & year == 2014
replace incumbent = 1 if prtvtdcz == 2 & year == 2014
replace election = 1 if country == 3 & year == 2014

replace pmright =1 if country == 3 & year == 2014

*/CSSD, KDU-CSL coalition 
replace incumbent = 1 if prtvtdcz == 2 & year == 2016
replace incumbent = 1 if prtvtdcz == 6 & year == 2016
replace election = 2 if country == 3 & year == 2016
replace pmleft =1 if country == 3 & year == 2016


*2018
replace LR = 1 if prtvtecz == 1
replace galtan = 6.5 if prtvtecz == 1
replace LR = 2.7 if prtvtecz == 2
replace galtan = 4.4 if prtvtecz == 2
replace LR = 7.8 if prtvtecz == 3
replace galtan = 5.5 if prtvtecz == 3
replace LR = 6.3 if prtvtecz == 4
replace galtan = 3.3 if prtvtecz == 4
replace LR = 8.1 if prtvtecz == 5
replace galtan = 6 if prtvtecz == 5
replace LR = 5.5 if prtvtecz == 6
replace galtan = 7.6 if prtvtecz == 6
replace LR = 5.3 if prtvtecz == 7
replace galtan = 7.7 if prtvtecz == 7

replace rleft = 1 if prtvtecz == 1
replace cleft = 1 if prtvtecz == 2
replace cleft = 1 if prtvtecz == 7
replace cright = 1 if prtvtecz == 3
replace cright = 1 if prtvtecz == 4
replace cright = 1 if prtvtecz == 5
replace cright = 1 if prtvtecz == 6
replace cright = 1 if prtvtecz == 9
replace rright = 1 if prtvtecz == 8

replace antielite = 5.8 if prtvtecz == 1
replace antielite = 1.5 if prtvtecz == 2
replace antielite = 1.9 if prtvtecz == 3
replace antielite = 7.7 if prtvtecz == 4
replace antielite = 2.1 if prtvtecz == 5
replace antielite = 2.4 if prtvtecz == 6
replace antielite = 7 if prtvtecz == 8


*/CSSD, ANO, KDU-CSL  coalition 
replace incumbent = 1 if prtvtecz == 1 & year == 2018
replace incumbent = 1 if prtvtecz == 5 & year == 2018
replace incumbent = 1 if prtvtecz == 6 & year == 2018
replace election = 3 if country == 3 & year == 2018
replace pmleft =1 if country == 3 & year == 2018


***** Denmark *****
*2012-2014
replace LR = 3.8 if prtvtcdk == 1
replace galtan = 5 if prtvtcdk == 1
replace LR = 6.3 if prtvtcdk == 2
replace galtan = 1.5 if prtvtcdk == 2
replace LR = 7.86 if prtvtcdk == 3
replace galtan = 6.6 if prtvtcdk == 3
replace LR = 2.2 if prtvtcdk == 4
replace galtan = 2.4 if prtvtcdk  == 4
replace LR = 5.4 if prtvtcdk  == 5
replace galtan = 9.3 if prtvtcdk  == 5
replace LR = 7 if prtvtcdk  == 7
replace galtan = 5.9 if prtvtcdk  == 7
replace LR = 9.1 if prtvtcdk == 8
replace galtan = 3 if prtvtcdk  == 8
replace LR = 0.8 if prtvtcdk  == 9
replace galtan = 1.7 if prtvtcdk  == 9


replace cleft = 1 if prtvtcdk  == 1
replace crigh = 1 if prtvtcdk  == 2
replace rleft = 1 if prtvtcdk  == 9
replace cright = 1 if prtvtcdk  == 3
replace cright = 1 if prtvtcdk  == 6
replace cright = 1 if prtvtcdk  == 7
replace cright = 1 if prtvtcdk  == 8 
replace rleft = 1 if prtvtcdk  == 4
replace rright = 1 if prtvtcdk == 5

replace antielite = 2.8 if prtvtcdk == 1
replace antielite = 1.1 if prtvtcdk== 2
replace antielite = 2.5 if prtvtcdk == 3
replace antielite = 2.9 if prtvtcdk == 4
replace antielite = 6.9 if prtvtcdk == 5
replace antielite = 2.8 if prtvtcdk == 7
replace antielite = 3.1 if prtvtcdk == 8
replace antielite = 5.9 if prtvtcdk == 9

*/ coalition Venstre, conservative peoples party
replace incumbent =1 if prtvtcdk == 7 & year == 2012
replace incumbent =1 if prtvtcdk == 3 & year == 2012

replace election = 1 if country == 4 & year == 2012
replace pmright =1 if country == 4 & year == 2012


*/ coalition Social democrats, radicale venstre
replace incumbent =1 if prtvtcdk == 2 & year == 2014
replace incumbent =1 if prtvtcdk == 1 & year == 2014
replace election = 1 if country == 4 & year == 2014
replace pmleft =1 if country == 4 & year == 2014

* no results 2016-2018


***** Estonia *****
*2012
replace LR = 7.5 if prtvtdee == 1
replace galtan = 6.5 if prtvtdee == 1
replace LR = 3 if prtvtdee == 2
replace galtan = 6.5 if prtvtdee == 2
replace LR = 8.5 if prtvtdee == 3
replace galtan = 4.8 if prtvtdee == 3
replace LR = 3.4 if prtvtdee == 4
replace galtan = 7.1 if prtvtdee == 4
replace LR = 5.3 if prtvtdee == 5
replace galtan = 2.8 if prtvtdee == 5

replace cright = 1 if prtvtdee ==1
replace cright = 1 if prtvtdee ==3
replace cright = 1 if prtvtdee ==7
replace cleft = 1 if prtvtdee ==2
replace cleft = 1 if prtvtdee ==5
replace cleft = 1 if prtvtdee ==6
replace rleft = 1 if prtvtdee ==9
replace rright = 1 if prtvtdee ==4
replace rright = 1 if prtvtdee ==8

*/ coalition reform, pro patria-res publica and social democrats
replace incumbent =1 if prtvtdee == 1 & year == 2012
replace incumbent =1 if prtvtdee == 3 & year == 2012
replace incumbent =1 if prtvtdee == 5 & year == 2012
replace election = 1 if country == 5 & year == 2012

replace pmright =1 if country == 5 & year == 2012


*2014
replace LR = 8.2 if prtvteee == 1
replace galtan = 3.1 if prtvteee == 1
replace LR = 3.8 if prtvteee == 2
replace galtan = 6.6 if prtvteee == 2
replace LR = 8.2 if prtvteee == 3
replace galtan = 6.6 if prtvteee == 3
replace LR = 4.2 if prtvteee == 4
replace galtan = 2.5 if prtvteee == 4
replace LR = 6 if prtvteee == 5
replace galtan = 4.2 if prtvteee == 5
replace LR = 8.2 if prtvteee == 6
replace galtan = 3.1 if prtvteee == 6
replace LR = 7.1 if prtvteee == 7
replace galtan = 2.8 if prtvteee == 7

replace cright = 1 if prtvteee ==1
replace cright = 1 if prtvteee ==3
replace cright = 1 if prtvteee ==8
replace cleft = 1 if prtvteee ==2
replace cleft = 1 if prtvteee ==4
replace cleft = 1 if prtvteee ==5
replace rright = 1 if prtvteee ==6
replace rright = 1 if prtvteee ==9

replace antielite = 1 if prtvteee == 1
replace antielite = 1 if prtvteee == 6
replace antielite = 4.7 if prtvteee == 2
replace antielite = 1.6 if prtvteee == 3
replace antielite = 3.2 if prtvteee == 4
replace antielite = 7.5 if prtvteee == 5
replace antielite = 8.3 if prtvteee == 7

*/ coalition reform, pro patria-res publica and social democrats
replace incumbent =1 if prtvteee == 1 & year == 2014
replace incumbent =1 if prtvteee == 3 & year == 2014
replace incumbent =1 if prtvteee == 4 & year == 2014
replace election = 1 if country == 5 & year == 2014

replace pmright =1 if country == 5 & year == 2014


* 2016 
replace LR = 8.2 if prtvtfee == 1
replace galtan = 3.1 if prtvtfee == 1
replace LR = 3.8 if prtvtfee == 2
replace galtan = 6.6 if prtvtfee == 2
replace LR = 8.2 if prtvtfee == 3
replace galtan = 6.6 if prtvtfee == 3
replace LR = 4.2 if prtvtfee == 4
replace galtan = 2.5 if prtvtfee == 4
replace LR = 6 if prtvtfee == 5
replace galtan = 4.2 if prtvtfee == 5
replace LR = 8.2 if prtvtfee == 6
replace galtan = 3.1 if prtvtfee == 6

replace cright = 1 if prtvtfee ==1
replace cright = 1 if prtvtfee ==3
replace cright = 1 if prtvtfee ==11
replace cleft = 1 if prtvtfee ==2
replace cleft = 1 if prtvtfee ==4
replace cleft = 1 if prtvtfee ==5
replace rleft = 1 if prtvtfee ==13
replace rright = 1 if prtvtfee ==6
replace rright = 1 if prtvtfee ==9

replace antielite = 1 if prtvtfee == 1
replace antielite = 1 if prtvtfee == 6
replace antielite = 4.7 if prtvtfee == 2
replace antielite = 1.6 if prtvtfee == 3
replace antielite = 3.2 if prtvtfee == 4
replace antielite = 7.5 if prtvtfee == 5


*/ coalition reform and social democrats
replace incumbent =1 if prtvtfee == 1 & year == 2016
replace incumbent =1 if prtvtfee == 4 & year == 2016
replace election = 2 if country == 5 & year == 2016
replace pmleft =1 if country == 5 & year == 2016

*2018 
replace LR = 8.2 if prtvtgee == 1
replace galtan = 3.1 if prtvtgee == 1
replace LR = 3.8 if prtvtgee == 2
replace galtan = 6.6 if prtvtgee == 2
replace LR = 8.2 if prtvtgee == 3
replace galtan = 6.6 if prtvtgee == 3
replace LR = 4.2 if prtvtgee == 4
replace galtan = 2.5 if prtvtgee == 4
replace LR = 6 if prtvtgee == 5
replace galtan = 4.2 if prtvtgee == 5
replace LR = 8.2 if prtvtgee == 6
replace galtan = 3.1 if prtvtgee == 6

replace antielite = 1 if prtvtgee == 1
replace antielite = 1 if prtvtgee == 6
replace antielite = 4.7 if prtvtgee == 2
replace antielite = 1.6 if prtvtgee == 3
replace antielite = 3.2 if prtvtgee == 4
replace antielite = 7.5 if prtvtgee == 5

replace cright = 1 if prtvtgee ==1
replace cright = 1 if prtvtgee ==3
replace cright = 1 if prtvtgee ==11
replace cleft = 1 if prtvtgee ==2
replace cleft = 1 if prtvtgee ==4
replace cleft = 1 if prtvtgee ==5
replace rright = 1 if prtvtgee ==6
replace rright = 1 if prtvtgee ==9

*/ coalition reform and social democrats
replace incumbent =1 if prtvtgee == 1 & year == 2018
replace incumbent =1 if prtvtgee == 4 & year == 2018
replace election = 2 if country == 5 & year == 2018
replace pmleft =1 if country == 5 & year == 2018


***** Finland *****

*2012-2014 
replace LR = 7.6 if prtvtcfi == 1
replace galtan = 5.7 if prtvtcfi == 1
replace LR = 7.09 if prtvtcfi == 2
replace galtan = 3.5 if prtvtcfi == 2
replace LR = 5 if prtvtcfi == 4
replace galtan = 6.9 if prtvtcfi == 4
replace LR = 4.8 if prtvtcfi == 5
replace galtan = 7.6 if prtvtcfi == 5
replace LR = 4.4 if prtvtcfi == 12
replace galtan = 2.1 if prtvtcfi == 12
replace LR = 3.5 if prtvtcfi == 13
replace galtan = 5 if prtvtcfi == 13
replace LR = 2 if prtvtcfi == 14
replace galtan = 3.5 if prtvtcfi == 14

replace cright = 1 if prtvtcfi == 1
replace cright = 1 if prtvtcfi == 2
replace cright = 1 if prtvtcfi == 3
replace cright = 1 if prtvtcfi == 5
replace cright = 1 if prtvtcfi == 6
replace cright = 1 if prtvtcfi == 8
replace cright = 1 if prtvtcfi == 9
replace cleft = 1 if prtvtcfi == 12
replace cleft = 1 if prtvtcfi == 13
replace cleft = 1 if prtvtcfi == 14
replace rleft = 1 if prtvtcfi == 15
replace rleft = 1 if prtvtcfi == 16
replace rleft = 1 if prtvtcfi == 17
replace rright = 1 if prtvtcfi == 4

replace antielite = 0.8 if prtvtcfi == 1
replace antielite = 1.1 if prtvtcfi == 2
replace antielite = 3.7 if prtvtcfi == 3
replace antielite = 9.1 if prtvtcfi == 4
replace antielite = 2.2 if prtvtcfi == 5
replace antielite = 4.2 if prtvtcfi == 12
replace antielite = 2.6 if prtvtcfi == 13
replace antielite = 6.2 if prtvtcfi == 14

*/ coalition centre, national coalition, green league and swedish peoples
replace incumbent =1 if prtvtcfi == 1 & year == 2012
replace incumbent =1 if prtvtcfi == 2 & year == 2012
replace incumbent =1 if prtvtcfi == 3 & year == 2012
replace incumbent =1 if prtvtcfi == 12 & year == 2012
replace election = 1 if country == 6 & year == 2012
replace pmright =1 if country == 6 & year == 2012



*/ coalition social democatic, left alliance, national coalition, green league, christian democrats and swedish peoples
replace incumbent =1 if prtvtcfi == 1 & year == 2014
replace incumbent =1 if prtvtcfi == 2 & year == 2014
replace incumbent =1 if prtvtcfi == 3 & year == 2014
replace incumbent =1 if prtvtcfi == 12 & year == 2014
replace election  =1 if country == 6 & year == 2014

replace pmright =1 if country == 6 & year == 2014

*2016-2018
replace LR = 8.2 if prtvtdfi == 1
replace galtan = 4.7 if prtvtdfi == 1
replace LR = 7.3 if prtvtdfi == 2
replace galtan = 2.1 if prtvtdfi == 2
replace LR = 5.4 if prtvtdfi == 3
replace galtan = 7 if prtvtdfi == 3
replace LR = 4.1 if prtvtdfi == 4
replace galtan = 9.1 if prtvtdfi == 4
replace LR = 5.4 if prtvtdfi == 5
replace galtan = 9 if prtvtdfi == 5
replace LR = 4.4 if prtvtdfi == 10
replace galtan = 0.7 if prtvtdfi == 10
replace LR = 3.4 if prtvtdfi == 11
replace galtan = 3.2 if prtvtdfi == 11
replace LR = 1.6 if prtvtdfi == 12
replace galtan = 1.8 if prtvtdfi == 12

replace cright = 1 if prtvtdfi == 1
replace cright = 1 if prtvtdfi == 2
replace cright = 1 if prtvtdfi == 3
replace cright = 1 if prtvtdfi == 5
replace cright = 1 if prtvtdfi == 6
replace cleft = 1 if prtvtdfi == 10
replace cleft = 1 if prtvtdfi == 11
replace cleft = 1 if prtvtdfi == 12
replace rleft = 1 if prtvtdfi == 13
replace rleft = 1 if prtvtdfi == 14
replace rleft = 1 if prtvtdfi == 15
replace rright = 1 if prtvtdfi == 4

replace antielite = 0.8 if prtvtdfi == 1
replace antielite = 1.1 if prtvtdfi == 2
replace antielite = 3.7 if prtvtdfi == 3
replace antielite = 9.1 if prtvtdfi == 4
replace antielite = 2.2 if prtvtdfi == 5
replace antielite = 4.2 if prtvtdfi == 10
replace antielite = 2.6 if prtvtdfi == 11
replace antielite = 6.2 if prtvtdfi == 12


*/ coalition scentre, coalition, green and swedish 


*/ coalition social democatic, national coalition, green league, christian democrats and swedish peoples
replace incumbent =1 if prtvtdfi == 1 & year == 2016
replace incumbent =1 if prtvtdfi == 2 & year == 2016
replace incumbent =1 if prtvtdfi == 5 & year == 2016
replace incumbent =1 if prtvtdfi == 11 & year == 2016
replace incumbent =1 if prtvtdfi == 10 & year == 2016
replace election  =2 if country == 6 & year == 2016
replace pmright =1 if country == 6 & year == 2016


*/ coalition social democatic, centre,  left alliance, green league and swedish peoples
replace incumbent =1 if prtvtdfi == 1 & year == 2018
replace incumbent =1 if prtvtdfi == 2 & year == 2018
replace incumbent =1 if prtvtdfi == 3 & year == 2018
replace incumbent =1 if prtvtdfi == 10 & year == 2018
replace incumbent =1 if prtvtdfi == 12 & year == 2018
replace election  =3 if country == 6 & year == 2018
replace pmright =1 if country == 6 & year == 2018


***** France *****
*2012-2016
*FDG calculated as PCF
replace LR = 5 if prtvtcfr == 1
replace galtan = 4.6 if prtvtcfr == 1
replace LR = 6.5 if prtvtcfr == 2
replace galtan = 9.5  if prtvtcfr == 2
replace LR = 0.7 if prtvtcfr == 6
replace galtan = 3.7 if prtvtcfr == 6
replace LR = 3.8 if prtvtcfr == 7
replace galtan = 2.8 if prtvtcfr == 7
replace LR = 6.1 if prtvtcfr == 8
replace galtan = 9 if prtvtcfr == 8
replace LR = 2.4 if prtvtcfr == 9
replace galtan = 2.3 if prtvtcfr == 9
replace LR = 5.5 if prtvtcfr == 10
replace galtan = 6.3 if prtvtcfr == 10
replace LR = 5.2 if prtvtcfr == 11
replace galtan = 4.7 if prtvtcfr == 11
replace LR = 2.6 if prtvtcfr == 12
replace galtan = 1.5 if prtvtcfr == 12

replace cright = 1 if prtvtcfr == 1
replace cright = 1 if prtvtcfr == 8
replace cright = 1 if prtvtcfr == 10
replace cright = 1 if prtvtcfr == 11
replace cleft = 1 if prtvtcfr == 2
replace cleft = 1 if prtvtcfr == 4
replace cleft = 1 if prtvtcfr == 12
replace cleft = 1 if prtvtcfr == 13
replace rright = 1 if prtvtcfr == 2
replace rright = 1 if prtvtcfr == 8
replace rleft = 1 if prtvtcfr == 5
replace rleft = 1 if prtvtcfr == 7
replace rleft = 1 if prtvtcfr == 6

replace antielite = 2.8 if prtvtcfr == 1
replace antielite = 9.5 if prtvtcfr == 2
replace antielite = 9 if prtvtcfr == 6
replace antielite = 3.7 if prtvtcfr == 7
replace antielite = 7.3 if prtvtcfr == 8
replace antielite = 3.2 if prtvtcfr == 9
replace antielite = 3 if prtvtcfr == 10
replace antielite = 5.3 if prtvtcfr == 11
replace antielite = 5.3 if prtvtcfr == 12

*/ UMP
replace incumbent =1 if prtvtcfr == 10 & year == 2012
replace election  =1 if country == 7 & year == 2012
replace pmright =1 if country == 7 & year == 2012



*/ UMP
replace incumbent =1 if prtvtcfr == 10 & year == 2014
replace election  =1 if country == 7 & year == 2014
replace pmright =1 if country == 7 & year == 2014


*/ PS
replace incumbent =1 if prtvtcfr == 9 & year == 2016
replace election  =2 if country == 7 & year == 2016
replace pmleft =1 if country == 7 & year == 2016


*2018
replace LR = 1.1 if prtvtdfr == 3
replace galtan = 3.9 if prtvtdfr == 3
replace LR = 3.8 if prtvtdfr == 5
replace galtan = 3.3 if prtvtdfr == 5
replace LR = 3.2 if prtvtdfr == 6
replace galtan = 1.4 if prtvtdfr == 6
replace LR = 6.4 if prtvtdfr == 8
replace galtan = 5.3 if prtvtdfr == 8
replace LR = 7.3 if prtvtdfr == 9
replace galtan = 7.1 if prtvtdfr == 9
replace LR = 5.9 if prtvtdfr == 11
replace galtan = 8.9 if prtvtdfr == 11
replace cright = 1 if prtvtdfr == 7
replace cright = 1 if prtvtdfr == 8
replace cright = 1 if prtvtdfr == 9
replace cright = 1 if prtvtdfr == 10
replace cleft = 1 if prtvtdfr == 5
replace cleft = 1 if prtvtdfr == 6
replace cleft = 1 if prtvtdfr == 1
replace rright = 1 if prtvtdfr == 11
replace rleft = 1 if prtvtdfr == 2
replace rleft = 1 if prtvtdfr == 3
replace rleft = 1 if prtvtdfr == 4

*/PS
replace incumbent =1 if prtvtdfr == 5 & year == 2018
replace election  =3 if country == 7 & year == 2018
replace pmleft =1 if country == 7 & year == 2018



***** Germany *****
*CDU/CSU coded as cdu and only 1st list
*2012
replace LR = 3 if prtvdde1 == 1
replace galtan = 4.5 if prtvdde1 == 1
replace LR = 6 if prtvdde1 == 2
replace galtan = 6.2 if prtvdde1 == 2
replace LR = 3.8 if prtvdde1 == 3
replace galtan = 1.8 if prtvdde1 == 3
replace LR = 8.1 if prtvdde1 == 4
replace galtan = 3.5 if prtvdde1 == 4
replace LR = 1 if prtvdde1 == 5
replace galtan = 4.6 if prtvdde1 == 5

replace cleft = 1 if prtvdde1 == 1
replace cleft = 1 if prtvdde1 == 3
replace cright = 1 if prtvdde1 == 2
replace cright = 1 if prtvdde1 == 4
replace rleft = 1 if prtvdde1 == 5
replace rright = 1 if prtvdde1 == 6
replace rright = 1 if prtvdde1 == 7

*/coalition CDU/CSU & SPD
replace incumbent = 1 if prtvdde1 == 1 & year == 2012
replace incumbent = 1 if prtvdde1 == 2 & year == 2012
replace election  = 1 if country == 8 & year == 2012
replace pmright =1 if country == 8 & year == 2012


*2014-2018
replace LR = 5.9 if prtvede1 == 1
replace galtan = 6 if prtvede1 == 1
replace LR = 3.5 if prtvede1 == 2
replace galtan = 4.1 if prtvede1 == 2
replace LR = 1.2 if prtvede1 == 3
replace galtan = 4.9 if prtvede1 == 3
replace LR = 3.5 if prtvede1 == 4
replace galtan = 2.1 if prtvede1 == 4
replace LR = 8 if prtvede1 == 5
replace galtan = 3.3 if prtvede1 == 5
replace LR = 8.3 if prtvede1 == 6
replace galtan = 8.6 if prtvede1 == 6
replace LR = 3.2 if prtvede1 == 7
replace galtan = 1.9 if prtvede1 == 7
replace LR = 5.3 if prtvede1 == 8
replace galtan = 9.8 if prtvede1 == 8

replace cleft = 1 if prtvede1 == 2
replace cleft = 1 if prtvede1 == 4
replace cright = 1 if prtvede1 == 1
replace cright = 1 if prtvede1 == 5
replace rleft = 1 if prtvede1 == 3
replace rright = 1 if prtvede1 == 6
replace rright = 1 if prtvede1 == 8

replace antielite = 0.8 if prtvede1 == 1
replace antielite = 1.3 if prtvede1 == 2
replace antielite = 5.4 if prtvede1 == 3
replace antielite = 2 if prtvede1 == 4
replace antielite = 0.8 if prtvede1 == 5
replace antielite = 7.7 if prtvede1 == 6
replace antielite = 6.8 if prtvede1 == 7
replace antielite = 9.1 if prtvede1 == 8

*/coalition CDU/CSU & FDP
replace incumbent = 1 if prtvede1 == 1 & year == 2014
replace incumbent = 1 if prtvede1 == 5 & year == 2014
replace election  = 2 if country == 8 & year == 2014
replace pmright =1 if country == 8 & year == 2014

Z
*/coalition CDU/CSU & FDP
replace incumbent = 1 if prtvede1 == 1 & year == 2016
replace incumbent = 1 if prtvede1 == 5 & year == 2016
replace election  = 2 if country == 8 & year == 2016
replace pmright =1 if country == 8 & year == 2016


*/coalition CDU/CSU & SDP
replace incumbent = 1 if prtvede1 == 1 & year == 2018
replace incumbent = 1 if prtvede1 == 2 & year == 2018
replace election  = 3 if country == 8 & year == 2018
replace pmright =1 if country == 8 & year == 2018


***** Hungary *****
*2002-2004(coalition fidesz and MDF coded as fidesz)
*2012
replace LR = 3.4 if prtvtdhu == 3
replace galtan = 7.1 if prtvtdhu == 3
replace LR = 3.1 if prtvtdhu == 4
replace galtan = 9.4 if prtvtdhu == 4
replace LR = 5.9 if prtvtdhu == 6
replace galtan = 6.4 if prtvtdhu == 6
replace LR = 4.1 if prtvtdhu == 8
replace galtan = 3.8 if prtvtdhu == 8
replace LR = 6.7 if prtvtdhu == 13
replace galtan = 1.4 if prtvtdhu == 13

replace rright = 1 if prtvtdhu == 3
replace cright =1 if prtvtdhu == 1
replace cright =1 if prtvtdhu == 2
replace cright =1 if prtvtdhu == 6
replace cright =1 if prtvtdhu == 13
replace cleft =1 if prtvtdhu == 5
replace cleft =1 if prtvtdhu == 8
replace cleft =1 if prtvtdhu == 9
replace rright = 1 if prtvtdhu == 7
replace rright = 1 if prtvtdhu == 4
replace rright = 1 if prtvtdhu == 3
replace rleft  = 1 if prtvtdhu == 10


*/ MSZP 
replace incumbent = 1 if prtvtdhu == 8 & year == 2012
replace election  = 1 if country == 10 & year == 2012
replace pmleft =1 if country == 10 & year == 2012


*2014-2016
replace LR = 3.6 if prtvtehu == 1
replace galtan = 8.6 if prtvtehu == 1
replace LR = 4 if prtvtehu == 2
replace galtan = 9.5 if prtvtehu == 2
replace LR = 3.6 if prtvtehu == 3
replace galtan = 2.9 if prtvtehu == 3
replace LR = 4 if prtvtehu == 4
replace galtan = 4 if prtvtehu == 4

replace rright = 1 if prtvtehu == 1
replace rright = 1 if prtvtehu == 2
replace cleft = 1 if prtvtehu == 3
replace cleft = 1 if prtvtehu == 4
replace rleft = 1 if prtvtehu == 5

replace antielite = 4.6 if prtvtehu == 1
replace antielite = 9 if prtvtehu == 2
replace antielite = 7.4 if prtvtehu == 3
replace antielite = 3.5 if prtvtehu == 4

*/ MSZP
replace incumbent = 1 if prtvtehu == 4 & year == 2014
replace election  = 1 if country == 10 & year == 2014
replace pmleft =1 if country == 10 & year == 2014

*/ Coalition FIDESZ & KDNP 
replace incumbent = 1 if prtvtehu == 1 & year == 2016
replace election  = 2 if country == 10 & year == 2016
replace pmrright =1 if country == 10 & year == 2016


*2018
replace LR = 4.8 if prtvtfhu == 1
replace galtan = 2.5 if prtvtfhu == 1
replace LR = 4.8 if prtvtfhu == 2
replace galtan = 2.3 if prtvtfhu == 2
replace LR = 3.6 if prtvtfhu == 3
replace galtan = 8.6 if prtvtfhu == 3
replace LR = 4 if prtvtfhu == 4
replace galtan = 9.5 if prtvtfhu == 4
replace LR = 3.6 if prtvtfhu == 6
replace galtan = 2.9 if prtvtfhu == 6
replace LR = 4 if prtvtfhu == 7
replace galtan = 4 if prtvtfhu == 7

replace cleft = 1 if prtvtfhu == 1
replace cleft = 1 if prtvtfhu == 6
replace cleft = 1 if prtvtfhu == 9
replace cright = 1 if prtvtfhu == 2
replace cright = 1 if prtvtfhu == 9
replace rright = 1 if prtvtfhu == 3
replace rright = 1 if prtvtfhu == 4
replace rright = 1 if prtvtfhu == 5
replace rleft = 1 if prtvtfhu == 8

replace antielite = 4.5 if prtvtfhu == 1
replace antielite = 5.2 if prtvtfhu == 2
replace antielite = 4.6 if prtvtfhu == 3
replace antielite = 9 if prtvtfhu == 4
replace antielite = 7.4 if prtvtfhu == 6
replace antielite = 3.5 if prtvtfhu == 7

*/ Coalition FIDESZ & KDNP 
replace incumbent = 1 if prtvtfhu == 3 & year == 2018
replace incumbent = 1 if prtvtfhu == 5 & year == 2018
replace election  = 3 if country == 10 & year == 2018
replace pmrright =1 if country == 10 & year == 2018


***** Ireland *****
*2010-2014
replace LR = 7.1 if prtvtaie == 1
replace galtan = 7.2 if prtvtaie == 1
replace LR = 7.5 if prtvtaie == 2
replace galtan = 6.3 if prtvtaie == 2
replace LR = 3.2 if prtvtaie == 3
replace galtan = 3.7 if prtvtaie == 3
replace LR = 3.5 if prtvtaie == 5
replace galtan = 3.7 if prtvtaie == 5
replace LR = 2.1 if prtvtaie == 6
replace galtan = 4.6 if prtvtaie == 6
replace LR = 0.4 if prtvtaie == 7
replace galtan = 1.2 if prtvtaie == 7
replace LR = 1.5 if prtvtaie == 8
replace galtan = 2 if prtvtaie == 8

replace cright = 1 if prtvtaie == 1
replace cright = 1 if prtvtaie == 2
replace cleft = 1 if prtvtaie == 3
replace cleft = 1 if prtvtaie == 5
replace cleft = 1 if prtvtaie == 7
replace cleft = 1 if prtvtaie == 9
replace rleft = 1 if prtvtaie == 6
replace rleft = 1 if prtvtaie == 8

replace antielite = 1.3 if prtvtaie == 1
replace antielite = 1.1 if prtvtaie == 2
replace antielite = 5 if prtvtaie == 3
replace antielite = 1.5 if prtvtaie == 5
replace antielite = 9.2 if prtvtaie == 6
replace antielite = 8.1 if prtvtaie == 7
replace antielite = 8.8 if prtvtaie == 8

*/ Coalition Fianna Fail, Green, progressive democrats
replace incumbent = 1 if prtvtaie == 1 & year == 2012
replace incumbent = 1 if prtvtaie == 3 & year == 2012
replace election  = 1 if country == 11 & year == 2012
replace pmright =1 if country == 11 & year == 2012

*/ Coalition Fianna Fail, Green, progressive democrats
replace incumbent = 1 if prtvtaie == 1 & year == 2014
replace incumbent = 1 if prtvtaie == 3 & year == 2014
replace election  = 1 if country == 11 & year == 2014
replace pmright =1 if country == 11 & year == 2014

*2016
replace LR = 0.4 if prtvtbie == 1
replace galtan = 1.2 if prtvtbie == 2
replace LR = 5.7 if prtvtbie == 2
replace galtan = 7.2 if prtvtbie == 2
replace LR = 7.1 if prtvtbie == 3
replace galtan = 6.3 if prtvtbie == 3
replace LR = 3.7 if prtvtbie == 4
replace galtan = 2.6 if prtvtbie == 4
replace LR = 4.1 if prtvtbie == 6
replace galtan = 3.7 if prtvtbie == 6
replace LR = 1.8 if prtvtbie == 7
replace galtan = 5.1 if prtvtbie == 7
replace LR = 0.5 if prtvtbie == 9
replace galtan = 1.8 if prtvtbie == 9

replace cright = 1 if prtvtbie == 2
replace cright = 1 if prtvtbie == 3
replace cleft = 1 if prtvtbie == 4
replace cleft = 1 if prtvtbie == 6
replace cleft = 1 if prtvtbie == 7
replace cleft = 1 if prtvtbie == 8
replace rleft = 1 if prtvtbie == 1
replace rleft = 1 if prtvtbie == 9

replace antielite = 9.2 if prtvtbie == 1
replace antielite = 1.3 if prtvtbie == 2
replace antielite = 1.1 if prtvtbie == 3
replace antielite = 5 if prtvtbie == 4
replace antielite = 1.5 if prtvtbie == 6
replace antielite = 8.1 if prtvtbie == 7
replace antielite = 8.8 if prtvtbie == 9


*/ Coalition Fine Gael & Labour
replace incumbent = 1 if prtvtbie == 3 & year == 2016
replace incumbent = 1 if prtvtbie == 5 & year == 2016
replace election  = 2 if country == 11 & year == 2016
replace pmright =1 if country == 11 & year == 2016

*2018 
*1st preference vote
replace LR = 5.7 if prtvtcie == 2
replace galtan = 7.2 if prtvtcie == 2
replace LR = 7.1 if prtvtcie == 3
replace galtan = 6.3 if prtvtcie == 3
replace LR = 3.7 if prtvtcie == 4
replace galtan = 2.6 if prtvtcie == 4
replace LR = 4.1 if prtvtcie == 6
replace galtan = 3.7 if prtvtcie == 6
replace LR = 1.8 if prtvtcie == 7
replace galtan = 5.1 if prtvtcie == 7
replace LR = 0.5 if prtvtcie == 9
replace galtan = 1.8 if prtvtcie == 9

replace cright = 1 if prtvtcie == 2
replace cright = 1 if prtvtcie == 3
replace cleft = 1 if prtvtcie == 4
replace cleft = 1 if prtvtcie == 5
replace cleft = 1 if prtvtcie == 6
replace cleft = 1 if prtvtcie == 7
replace cleft = 1 if prtvtcie == 8
replace rleft = 1 if prtvtcie == 1
replace rleft = 1 if prtvtcie == 9

replace antielite = 9.2 if prtvtcie == 1
replace antielite = 1.3 if prtvtcie == 2
replace antielite = 1.1 if prtvtcie == 3
replace antielite = 5 if prtvtcie == 4
replace antielite = 1.5 if prtvtcie == 6
replace antielite = 8.1 if prtvtcie == 7
replace antielite = 8.8 if prtvtcie == 9


*/ Coalition Fine Gael & independent
replace incumbent = 1 if prtvtcie == 3 & year == 2018
replace incumbent = 1 if prtvtcie == 5 & year == 2018
replace election  = 3 if country == 11 & year == 2018
replace pmright =1 if country == 11 & year == 2018

***** Italy *****
*CCD-CDU coded as CDU
*2012-2016
replace LR = 3.5 if prtvtbit == 1
replace galtan = 3.1 if prtvtbit == 1
replace LR = 1.7 if prtvtbit == 2
replace galtan = 0.7 if prtvtbit == 2
replace LR = 0.6 if prtvtbit == 3
replace galtan = 0.7 if prtvtbit == 3
replace LR = 5 if prtvtbit == 6
replace galtan = 7.4 if prtvtbit == 6
replace LR = 7.5 if prtvtbit == 8
replace galtan = 8.4 if prtvtbit == 8
replace LR = 7.3 if prtvtbit == 9
replace galtan = 8.4 if prtvtbit == 9

replace cleft = 1 if prtvtbit == 1
replace cleft = 1 if prtvtbit == 2
replace cleft = 1 if prtvtbit == 11
replace cleft = 1 if prtvtbit == 14
replace cleft = 1 if prtvtbit == 4
replace cright = 1 if prtvtbit == 5
replace cright = 1 if prtvtbit == 6
replace cright = 1 if prtvtbit == 7
replace cright = 1 if prtvtbit == 12
replace cright = 1 if prtvtbit == 13
replace rleft = 1 if prtvtbit == 3
replace rright = 1 if prtvtbit == 9
replace rright = 1 if prtvtbit == 10
replace rright = 1 if prtvtbit == 8

replace antielite = 4.4 if prtvtbit == 1
replace antielite = 6.8 if prtvtbit == 2
replace antielite = 9.3 if prtvtbit == 3
replace antielite = 10 if prtvtbit == 4
replace antielite = 1 if prtvtbit == 5
replace antielite = 1.5 if prtvtbit == 6
replace antielite = 4 if prtvtbit == 7
replace antielite = 8.8 if prtvtbit == 9
replace antielite = 6.2 if prtvtbit == 10

*/coalition 
replace incumbent = 1 if prtvtbit == 1 & year == 2012
replace incumbent = 1 if prtvtbit == 2 & year == 2012
replace incumbent = 1 if prtvtbit == 11 & year == 2012
replace election  = 1 if country == 12 & year == 2012
replace pmleft =1 if country == 12 & year == 2012

*/coalition 
replace incumbent = 1 if prtvtbit == 8 & year == 2016
replace incumbent = 1 if prtvtbit == 9 & year == 2016
replace election  = 2 if country == 12 & year == 2016
replace pmleft =1 if country == 12 & year == 2016

*2018 (under advisement)
*SVP-PATT coded as SVP
replace LR = 4.5 if prtvtcit == 1
replace galtan = 2.4  if prtvtcit == 1
replace LR = 5.4 if prtvtcit == 5
replace galtan = 7.2  if prtvtcit == 5
replace LR = 3.4 if prtvtcit == 7
replace galtan = 2.5  if prtvtcit == 7
replace LR = 7 if prtvtcit == 8
replace galtan = 7.2 if prtvtcit == 8
replace LR = 7.2 if prtvtcit == 9
replace galtan = 9.1 if prtvtcit == 9
replace LR = 5.5 if prtvtcit == 10
replace galtan = 9.2  if prtvtcit == 10
replace LR = 5.2 if prtvtcit == 11
replace galtan = 7.8  if prtvtcit == 11

replace cleft = 1 if prtvtcit == 1
replace cleft = 1 if prtvtcit == 2
replace cleft = 1 if prtvtcit == 3
replace cleft = 1 if prtvtcit == 4
replace cleft = 1 if prtvtcit == 6
replace cleft = 1 if prtvtcit == 14
replace cright = 1 if prtvtcit == 8
replace cright = 1 if prtvtcit == 5
replace cright = 1 if prtvtcit == 11
replace rright = 1 if prtvtcit == 9
replace rright = 1 if prtvtcit == 10
replace rright = 1 if prtvtcit == 13
replace cleft = 1 if prtvtcit == 7
replace rleft = 1 if prtvtcit == 12

replace antielite =  4.4 if prtvtcit == 1
replace antielite =  5 if prtvtcit == 5
replace antielite =  10 if prtvtcit == 7
replace antielite =  4 if prtvtcit == 8
replace antielite =  8.8 if prtvtcit == 9
replace antielite =  6.2 if prtvtcit == 10

*/coalition 
replace incumbent = 1 if prtvtcit == 1 & year == 2018
replace election  = 3 if country == 12 & year == 2018
replace pmleft =1 if country == 12 & year == 2018


***** Netherlands *****
*2012
replace LR = 8.2 if prtvtenl == 1
replace galtan = 4.7 if prtvtenl == 1
replace LR = 3.5 if prtvtenl == 2
replace galtan = 4 if prtvtenl == 2
replace LR = 5.2 if prtvtenl == 3
replace galtan = 7.1 if prtvtenl == 3
replace LR = 6.5 if prtvtenl == 4
replace galtan = 7.1 if prtvtenl == 4
replace LR = 1.5 if prtvtenl == 5
replace galtan = 5.2 if prtvtenl == 5
replace LR = 5.5 if prtvtenl == 6
replace galtan = 1.5 if prtvtenl == 6
replace LR = 3 if prtvtenl == 7
replace galtan = 1.9 if prtvtenl == 7
replace LR = 5 if prtvtenl == 8
replace galtan = 7.4 if prtvtenl == 8
replace LR = 6.5 if prtvtenl == 9
replace galtan = 9.2 if prtvtenl == 9
replace LR = 3.5 if prtvtenl == 10
replace galtan = 3.8 if prtvtenl == 10

replace cleft = 1 if prtvtenl == 2
replace cleft = 1 if prtvtenl == 6
replace cleft = 1 if prtvtenl == 7
replace cright = 1 if prtvtenl == 1
replace cright = 1 if prtvtenl == 4
replace cright = 1 if prtvtenl == 8
replace cright = 1 if prtvtenl == 9
replace cright = 1 if prtvtenl == 12
replace rleft = 1 if prtvtenl == 5
replace rright = 1 if prtvtenl == 3

*/coalition VVD & CDA
replace incumbent = 1 if prtvtenl == 1 & year == 2012
replace incumbent = 1 if prtvtenl == 4 & year == 2012
replace election  = 1 if country == 13 & year == 2012
replace pmright =1 if country == 13 & year == 2012


*2014-2016
replace LR = 8.2 if prtvtfnl == 1
replace galtan = 4.7 if prtvtfnl == 1
replace LR = 3.5 if prtvtfnl == 2
replace galtan = 4 if prtvtfnl == 2
replace LR = 5.2 if prtvtfnl == 3
replace galtan = 7.1 if prtvtfnl == 3
replace LR = 1.5 if prtvtfnl == 4
replace galtan = 5.2 if prtvtfnl == 4
replace LR = 6.5 if prtvtfnl == 5
replace galtan = 7.1 if prtvtfnl == 5
replace LR = 5.5 if prtvtfnl == 6
replace galtan = 1.5 if prtvtfnl == 6
replace LR = 5 if prtvtfnl == 7
replace galtan = 7.4 if prtvtfnl == 7
replace LR = 3 if prtvtfnl == 8
replace galtan = 1.9 if prtvtfnl == 8
replace LR = 6.5 if prtvtfnl == 9
replace galtan = 9.2 if prtvtfnl == 9
replace LR = 3.5 if prtvtfnl == 10
replace galtan = 3.8 if prtvtfnl == 10

replace cleft = 1 if prtvtfnl== 2
replace cleft = 1 if prtvtfnl== 6
replace cleft = 1 if prtvtfnl== 8
replace cright = 1 if prtvtfnl== 1
replace cright = 1 if prtvtfnl== 5
replace cright = 1 if prtvtfnl== 7
replace cright = 1 if prtvtfnl== 9
replace rleft = 1 if prtvtfnl== 4
replace rright = 1 if prtvtfnl == 3

replace antielite = 1.7 if prtvtfnl == 1
replace antielite = 1.2 if prtvtfnl == 2
replace antielite = 9.4 if prtvtfnl == 3
replace antielite = 6.5 if prtvtfnl == 4
replace antielite = 1.4 if prtvtfnl == 5
replace antielite = 1.4 if prtvtfnl == 6
replace antielite = 2.1 if prtvtfnl == 7
replace antielite = 1.7 if prtvtfnl == 8
replace antielite = 1.1 if prtvtfnl == 9
replace antielite = 5 if prtvtfnl == 10
replace antielite = 5.8 if prtvtfnl == 11


*/coalition VVD & CDA
replace incumbent = 1 if prtvtfnl == 1 & year == 2014
replace incumbent = 1 if prtvtfnl == 5 & year == 2014
replace election  = 1 if country == 13 & year == 2014
replace pmright =1 if country == 13 & year == 2014

*/coalition VVD & PVDA
replace incumbent = 1 if prtvtfnl == 1 & year == 2016
replace incumbent = 1 if prtvtfnl == 2 & year == 2016
replace election  = 2 if country == 13 & year == 2016
replace pmright =1 if country == 13 & year == 2016

*2018 
replace LR = 8.3 if prtvtgnl == 1
replace galtan = 5.1 if prtvtgnl == 1
replace LR = 3.2 if prtvtgnl == 2
replace galtan = 3 if prtvtgnl == 2
replace LR = 4.5 if prtvtgnl == 3
replace galtan = 7.7 if prtvtgnl == 3
replace LR = 1 if prtvtgnl == 4
replace galtan = 4.1 if prtvtgnl == 4
replace LR = 6.5 if prtvtgnl == 5
replace galtan = 6.4 if prtvtgnl == 5
replace LR = 6.5 if prtvtgnl == 6
replace galtan = 1 if prtvtgnl == 6
replace LR = 4.1 if prtvtgnl == 7
replace galtan = 7.6 if prtvtgnl == 7
replace LR = 1 if prtvtgnl == 8
replace galtan = 2.6 if prtvtgnl == 8
replace LR = 6.8 if prtvtgnl == 9
replace galtan = 9.4 if prtvtgnl == 9
replace LR = 2.4 if prtvtgnl == 10
replace galtan = 2.3 if prtvtgnl == 10
replace LR = 3.6 if prtvtgnl == 11
replace galtan = 4.3 if prtvtgnl == 11

replace cleft = 1 if prtvtgnl == 2
replace cleft = 1 if prtvtgnl == 6
replace cleft = 1 if prtvtgnl == 8
replace cright = 1 if prtvtgnl == 1
replace cright = 1 if prtvtgnl == 5
replace cright = 1 if prtvtgnl == 7
replace cright = 1 if prtvtgnl == 9
replace cright = 1 if prtvtgnl == 11
replace rleft = 1 if prtvtgnl == 4
replace rright = 1 if prtvtgnl == 3
replace rright = 1 if prtvtgnl == 13

replace antielite = 1.7 if prtvtgnl == 1
replace antielite = 1.2 if prtvtgnl == 2
replace antielite = 9.4 if prtvtgnl == 3
replace antielite = 6.5 if prtvtgnl == 4
replace antielite = 1.4 if prtvtgnl == 5
replace antielite = 1.4 if prtvtgnl == 6
replace antielite = 2.1 if prtvtgnl == 7
replace antielite = 1.7 if prtvtgnl == 8
replace antielite = 1.1 if prtvtgnl == 9
replace antielite = 5 if prtvtgnl == 10
replace antielite = 5.8 if prtvtgnl == 11

*/coalition VVD & PVDA
replace incumbent = 1 if prtvtgnl == 1 
replace incumbent = 1 if prtvtgnl == 2 
replace election  = 3 if country == 13 & year == 2018
replace pmright =1 if country == 13 & year == 2018

***** Poland *****
*2012-2014
replace LR = 9.5 if prtvtcpl == 1
replace galtan = 8.8 if prtvtcpl == 1
replace LR = 6.6 if prtvtcpl == 2
replace galtan = 5 if prtvtcpl == 2
replace LR = 4 if prtvtcpl == 5
replace galtan = 6.8 if prtvtcpl == 5
replace LR = 3.6 if prtvtcpl == 6
replace galtan = 8.6 if prtvtcpl == 6
replace LR = 3.4 if prtvtcpl == 8
replace galtan = 2.4 if prtvtcpl == 8

replace cright = 1 if prtvtcpl == 2
replace cright = 1 if prtvtcpl == 3
replace cleft = 1 if prtvtcpl == 4
replace cleft = 1 if prtvtcpl == 7
replace cleft = 1 if prtvtcpl == 8
replace rright = 1 if prtvtcpl == 1
replace rright = 1 if prtvtcpl == 6

replace antielite = 9.4 if prtvtcpl == 1
replace antielite = 1.4 if prtvtcpl == 2
replace antielite = 2.4 if prtvtcpl == 5
replace antielite = 7.4 if prtvtcpl == 6
replace antielite = 2.8 if prtvtcpl == 8

*/coalition Civic platform and polish peasants
replace incumbent = 1 if prtvtcpl == 1 & year == 2012
replace incumbent = 1 if prtvtcpl == 5 & year == 2012
replace election  = 1 if country == 14 & year == 2012
replace pmright =1 if country == 14 & year == 2012

*/coalition Civic platform and polish peasants
replace incumbent = 1 if prtvtcpl == 2 & year == 2014
replace incumbent = 1 if prtvtcpl == 5 & year == 2014
replace election  = 1 if country == 14 & year == 2014
replace pmright =1 if country == 14 & year == 2014

*2016-2018
replace LR = 6.2 if prtvtdpl == 4
replace galtan = 4.5 if prtvtdpl == 4
replace LR = 3.5 if prtvtdpl == 6
replace galtan = 8.4 if prtvtdpl == 6
replace LR = 3.1 if prtvtdpl == 8
replace galtan = 2.7 if prtvtdpl == 5

replace cright = 1 if prtvtdpl == 3
replace cright = 1 if prtvtdpl == 4
replace cright = 1 if prtvtdpl == 5
replace cleft = 1 if prtvtdpl == 7
replace cleft = 1 if prtvtdpl == 8
replace rright = 1 if prtvtdpl == 1
replace rright = 1 if prtvtdpl == 2
replace rright = 1 if prtvtdpl == 6

replace antielite = 1.4 if prtvtdpl == 4
replace antielite = 7.4 if prtvtdpl == 6
replace antielite = 2.4 if prtvtdpl == 5
replace antielite = 2.8 if prtvtdpl == 8

*/coalition Civic platform and polish peasants
replace incumbent = 1 if prtvtdpl == 4 & year == 2016
replace incumbent = 1 if prtvtdpl == 5 & year == 2016
replace election  = 2 if country == 14 & year == 2016
 replace pmright =1 if country == 14 & year == 2016

*/coalition Civic platform and polish peasants
replace incumbent = 1 if prtvtdpl == 4 & year == 2018
replace incumbent = 1 if prtvtdpl == 5 & year == 2018
replace election  = 2 if country == 14 & year == 2018
replace pmright =1 if country == 14 & year == 2018


***** Portugal *****
*2010-2014
replace LR = 1 if prtvtbpt == 1
replace galtan = 0.1 if prtvtbpt == 1
replace LR = 8.1 if prtvtbpt == 2
replace galtan = 8.8 if prtvtbpt == 2
replace LR = 0.5 if prtvtbpt == 3
replace galtan = 1.6 if prtvtbpt == 3
replace LR = 7 if prtvtbpt == 10
replace galtan = 6.8 if prtvtbpt == 10
replace LR = 4 if prtvtbpt == 11
replace galtan = 2.3 if prtvtbpt == 11

replace cleft = 1 if prtvtbpt == 1
replace cleft = 1 if prtvtbpt == 1
replace cleft = 1 if prtvtbpt == 6
replace cleft = 1 if prtvtbpt == 10
replace cleft = 1 if prtvtbpt == 11
replace cright = 1 if prtvtbpt == 2
replace rleft = 1 if prtvtbpt == 4
replace rleft = 1 if prtvtbpt == 3
replace rleft = 1 if prtvtbpt == 9
replace rright = 1 if prtvtbpt == 8
replace rright = 1 if prtvtbpt == 7

replace antielite = 7.5 if prtvtbpt == 1
replace antielite = 0.6 if prtvtbpt == 2
replace antielite = 7.5 if prtvtbpt == 3
replace antielite = 0.5 if prtvtbpt == 10
replace antielite = 2 if prtvtbpt == 11

*/coalition Socialist party
replace incumbent = 1 if prtvtbpt == 11 & year == 2012
replace election  = 1 if country == 15 & year == 2012
replace pmleft =1 if country == 15 & year == 2012


*/coalition Socialist party
replace incumbent = 1 if prtvtbpt == 11 & year == 2014
replace election  = 1 if country == 15 & year == 2014
replace pmleft =1 if country == 15 & year == 2014


*2016-2018
*Portugal a frente alliance coded as PDS
replace LR = 0.6 if prtvtcpt == 2
replace galtan = 0.6 if prtvtcpt == 2
replace LR = 0.3 if prtvtcpt == 3
replace galtan = 4 if prtvtcpt == 3
replace LR = 7 if prtvtcpt == 9
replace galtan = 7.3 if prtvtcpt == 9
replace LR = 4.6 if prtvtcpt == 13
replace galtan = 3.1 if prtvtcpt == 13
replace LR = 7.8 if prtvtcpt == 16
replace galtan = 5.6 if prtvtcpt == 16

replace cleft = 1 if prtvtcpt == 1
replace cleft = 1 if prtvtcpt == 2
replace cleft = 1 if prtvtcpt == 4
replace cleft = 1 if prtvtcpt == 5
replace cleft = 1 if prtvtcpt == 6
replace cleft = 1 if prtvtcpt == 13
replace cright = 1 if prtvtcpt == 7
replace cright = 1 if prtvtcpt == 9
replace cright = 1 if prtvtcpt == 10
replace cright = 1 if prtvtcpt == 12
replace cright = 1 if prtvtcpt == 14
replace cright = 1 if prtvtcpt == 16
replace rright = 1 if prtvtcpt == 11
replace rleft = 1 if prtvtcpt == 3
replace rleft = 1 if prtvtcpt == 8

replace antielite = 7.5 if prtvtcpt == 2
replace antielite = 8 if prtvtcpt == 9
replace antielite  = 0.5 if prtvtcpt == 16
replace antielite  = 2 if prtvtcpt == 13

*/coalition CDS-Social democrats
replace incumbent = 1 if prtvtcpt == 16 & year == 2016
replace election  = 2 if country == 15 & year == 2016
replace pmright =1 if country == 15 & year == 2016

 
*/coalition CDS-Social democrats
replace incumbent = 1 if prtvtcpt == 16 & year == 2018
replace election  = 2 if country == 15 & year == 2018
 replace pmright =1 if country == 15 & year == 2018
 
 */Alteernative  Socialists
// replace incumbent = 1 if prtvtcpt == 13 & year == 2018

***** Slovakia ***** (under advisement)
*2012
replace LR = 7.3 if prtvtcsk == 2
replace galtan = 4.5 if prtvtcsk == 2
replace LR = 3 if prtvtcsk == 3
replace galtan = 4.4 if prtvtcsk == 3
replace LR = 6.2 if prtvtcsk == 4
replace galtan = 5.2 if prtvtcsk == 4
replace LR = 6.2 if prtvtcsk == 5
replace galtan = 8.3 if prtvtcsk == 5
replace LR = 8.3 if prtvtcsk == 6
replace galtan = 1.5 if prtvtcsk == 6

replace cright = 1 if prtvtcsk == 1
replace cright = 1 if prtvtcsk == 2
replace cright = 1 if prtvtcsk == 4
replace cright = 1 if prtvtcsk == 5
replace cright = 1 if prtvtcsk == 6

replace cleft = 1 if prtvtcsk == 3

*/coalition SDKU-DS, SaS, KDH, Most-HiD
replace incumbent = 1 if prtvtcsk == 2 & year == 2012
replace incumbent = 1 if prtvtcsk == 4 & year == 2012
replace incumbent = 1 if prtvtcsk == 5 & year == 2012
replace incumbent = 1 if prtvtcsk == 6 & year == 2012
replace election  = 1 if country == 16 & year == 2012

replace pmright =1 if country == 16 & year == 2012

*no result 2014-2016

*2018
replace LR = 6.5 if prtvtdsk == 1
replace galtan = 8 if prtvtdsk == 1
replace LR = 4.7 if prtvtdsk == 2
replace galtan = 9.3 if prtvtdsk == 2
replace LR = 2.5 if prtvtdsk == 3
replace galtan = 6.9 if prtvtdsk == 3
replace LR = 6.3 if prtvtdsk == 4
replace galtan = 5.7 if prtvtdsk == 4
replace LR = 8.5 if prtvtdsk == 6
replace galtan = 3.7 if prtvtdsk == 6
replace LR = 7.1 if prtvtdsk == 7
replace galtan = 7.1 if prtvtdsk == 7

replace cleft = 1 if prtvtdsk == 3
replace rright = 1 if prtvtdsk == 2
replace rright = 1 if prtvtdsk == 5
replace rright = 1 if prtvtdsk == 8
replace cright = 1 if prtvtdsk == 4
replace cright = 1 if prtvtdsk == 7
replace cright = 1 if prtvtdsk == 6
replace cright = 1 if prtvtdsk == 1

replace antielite = 8.4 if prtvtdsk == 1
replace antielite = 7 if prtvtdsk == 2
replace antielite = 3.7 if prtvtdsk == 3
replace antielite = 3.5 if prtvtdsk == 4
replace antielite = 5.6 if prtvtdsk == 6
replace antielite = 5.7 if prtvtdsk == 7

*/coalition SMER-SD
replace incumbent = 1 if prtvtdsk == 3 & year == 2018
replace election  = 2 if country == 16 & year == 2018
replace pmleft =1 if country == 16 & year == 2018



***** Slovenia ***** (under advisement)
*2012
replace LR = 3.3 if prtvtdsi == 1
replace galtan = 5.1 if prtvtdsi == 1
replace LR = 5.8 if prtvtdsi == 2
replace galtan = 1.5 if prtvtdsi == 2
replace LR = 6.3 if prtvtdsi == 3
replace galtan = 9.3 if prtvtdsi == 3
replace LR = 5.9 if prtvtdsi == 4
replace galtan = 7.7 if prtvtdsi == 4
replace LR = 5.3 if prtvtdsi == 5
replace galtan = 7.8 if prtvtdsi == 5
replace LR = 3.7 if prtvtdsi == 6
replace galtan = 2.5 if prtvtdsi == 6
replace LR = 4.5 if prtvtdsi == 9
replace galtan = 1.7 if prtvtdsi == 9
replace LR = 6 if prtvtdsi == 10
replace galtan = 8.5 if prtvtdsi == 10

replace cleft = 1 if prtvtdsi == 1
replace cleft = 1 if prtvtdsi == 6
replace cleft = 1 if prtvtdsi == 9
replace cleft = 1 if prtvtdsi == 11
replace cleft = 1 if prtvtdsi == 7
replace cright = 1 if prtvtdsi == 2
replace cright = 1 if prtvtdsi == 3
replace cright = 1 if prtvtdsi == 5
replace cright = 1 if prtvtdsi == 8
replace rright = 1 if prtvtdsi == 4
replace rright = 1 if prtvtdsi == 10

*/coalition Social democrats, Zares, Pensioners and Liberal democracy of Slovenia
replace incumbent = 1 if prtvtdsi == 1 & year == 2012
replace incumbent = 1 if prtvtdsi == 6 & year == 2012
replace incumbent = 1 if prtvtdsi == 2 & year == 2012
replace incumbent = 1 if prtvtdsi == 9 & year == 2012
replace election  = 1 if country == 17 & year == 2012
replace pmleft =1 if country == 17 & year == 2012

*2014-2016
replace LR = 3.3 if prtvtesi == 1
replace galtan = 5.1 if prtvtesi == 1
replace LR = 6.3 if prtvtesi == 3
replace galtan = 9.3 if prtvtesi == 3
replace LR = 4.1 if prtvtesi == 4
replace galtan = 3.4 if prtvtesi == 4
replace LR = 3.7 if prtvtesi == 5
replace galtan = 2.5 if prtvtesi == 5
replace LR = 5.9 if prtvtesi == 6
replace galtan = 7.7 if prtvtesi == 6
replace LR = 5.3 if prtvtesi == 7
replace galtan = 7.8 if prtvtesi == 7
replace LR = 4.3 if prtvtesi == 8
replace galtan = 5.3 if prtvtesi == 8
replace LR = 0.6 if prtvtesi == 11
replace galtan = 1.3 if prtvtesi == 11
replace LR = 4.6 if prtvtesi == 10
replace galtan = 3.3 if prtvtesi == 10

replace cleft = 1 if prtvtesi == 1
replace cleft = 1 if prtvtesi == 4
replace cleft = 1 if prtvtesi == 5
replace cleft = 1 if prtvtesi == 9
replace cleft = 1 if prtvtesi == 10
replace cleft = 1 if prtvtesi == 11
replace cright = 1 if prtvtesi == 2
replace cright = 1 if prtvtesi == 3
replace cright = 1 if prtvtesi == 7
replace cright = 1 if prtvtesi == 8
replace rright = 1 if prtvtesi == 6

replace antielite = 4.5 if prtvtesi == 1
replace antielite = 5.8 if prtvtesi == 3
replace antielite = 4.6 if prtvtesi == 4
replace antielite = 4.1 if prtvtesi == 5
replace antielite = 6.6 if prtvtesi == 6
replace antielite = 5 if prtvtesi == 7
replace antielite = 4.7 if prtvtesi == 8
replace antielite = 6.7 if prtvtesi == 11
replace antielite = 4.2 if prtvtesi == 10

*/coalition DESUS, SD, PS, ZAAB, DL
replace incumbent = 1 if prtvtesi == 1 & year == 2014
replace incumbent = 1 if prtvtesi == 2 & year == 2014
replace incumbent = 1 if prtvtesi == 4 & year == 2014
replace incumbent = 1 if prtvtesi == 5 & year == 2014
replace incumbent = 1 if prtvtesi == 10 & year == 2014
replace election  = 2 if country == 17 & year == 2014
replace pmleft =1 if country == 17 & year == 2014

*/coalition DESUS, SD, PS, ZAAB, DL
replace incumbent = 1 if prtvtesi == 1 & year == 2016
replace incumbent = 1 if prtvtesi == 2 & year == 2016
replace incumbent = 1 if prtvtesi == 4 & year == 2016
replace incumbent = 1 if prtvtesi == 5 & year == 2016
replace incumbent = 1 if prtvtesi == 10 & year == 2016
replace election  = 2 if country == 17 & year == 2016
replace pmleft =1 if country == 17 & year == 2016

*2018 
replace LR = 4 if prtvtfsi == 1
replace galtan = 5.3 if prtvtfsi == 1
replace LR = 8 if prtvtfsi == 4
replace galtan = 8 if prtvtfsi == 4
replace LR = 4 if prtvtfsi == 5
replace galtan = 3.4 if prtvtfsi == 5
replace LR = 3.4 if prtvtfsi == 6
replace galtan = 3.5 if prtvtfsi == 6
replace LR = 8.6 if prtvtfsi == 8
replace galtan = 8.3 if prtvtfsi == 8
replace LR = 6.3 if prtvtfsi == 9
replace galtan = 7 if prtvtfsi == 9
replace LR = 5.3 if prtvtfsi == 10
replace galtan = 4.3 if prtvtfsi == 10

replace cleft = 1 if prtvtfsi == 1
replace cleft = 1 if prtvtfsi == 2
replace cleft = 1 if prtvtfsi == 3
replace cleft = 1 if prtvtfsi == 6
replace cleft = 1 if prtvtfsi == 5
replace cleft = 1 if prtvtfsi == 7
replace cright = 1 if prtvtfsi == 4
replace cright = 1 if prtvtfsi == 9
replace cright = 1 if prtvtfsi == 10
replace rright = 1 if prtvtfsi == 8
replace rright = 1 if prtvtfsi == 11

replace antielite = 4.5 if prtvtfsi == 1
replace antielite = 5.8 if prtvtfsi == 4
replace antielite = 4.6 if prtvtfsi == 5
replace antielite = 4.1 if prtvtfsi == 6
replace antielite = 6.6 if prtvtfsi == 8
replace antielite = 5 if prtvtfsi == 9
replace antielite = 4.7 if prtvtfsi == 10

*/coalition SMC, SD, DESUS & indep.
replace incumbent = 1 if prtvtfsi == 1 & year == 2018
replace incumbent = 1 if prtvtfsi == 10 & year == 2018
replace incumbent = 1 if prtvtfsi == 5 & year == 2018
replace election  = 3 if country == 17 & year == 2018
replace pmright =1 if country == 17 & year == 2018

***** Spain ***** 
*2012-2014
replace LR = 7.6 if prtvtces == 1
replace galtan = 8.1 if prtvtces == 1
replace LR = 3.5 if prtvtces == 2
replace galtan = 2.3 if prtvtces == 2
replace LR = 6.5 if prtvtces == 3
replace galtan = 6.3 if prtvtces == 3
replace LR = 1.3 if prtvtces == 4
replace galtan = 1.1 if prtvtces == 4
replace LR = 1.4 if prtvtces == 4
replace galtan = 2.1 if prtvtces == 4
replace LR = 4.6 if prtvtces == 6
replace galtan = 3.5 if prtvtces == 6
replace LR = 6.1 if prtvtces == 7
replace galtan = 6.2 if prtvtces == 7
replace LR = 7.2 if prtvtces == 8
replace galtan = 2 if prtvtces == 8
replace LR = 2. if prtvtces == 9
replace galtan = 1.6 if prtvtces == 9
replace LR = 6 if prtvtces == 10
replace galtan = 6 if prtvtces == 10

replace cright = 1 if prtvtces == 1
replace cright = 1 if prtvtces == 3
replace cright = 1 if prtvtces == 7
replace cright = 1 if prtvtces == 9
replace cright = 1 if prtvtces == 10
replace cleft = 1 if prtvtces == 2
replace cleft = 1 if prtvtces == 5
replace cleft = 1 if prtvtces == 6
replace cleft = 1 if prtvtces == 8
replace cleft = 1 if prtvtces == 11
replace cleft = 1 if prtvtces == 12
replace rleft = 1 if prtvtces == 4

replace antielite = 1.4 if prtvtces == 1
replace antielite = 3 if prtvtces == 2
replace antielite = 1.9 if prtvtces == 3
replace antielite = 5.5 if prtvtces == 4
replace antielite = 5.3 if prtvtces == 5
replace antielite = 6.7 if prtvtces == 6
replace antielite = 1.9 if prtvtces == 7
replace antielite = 4.2 if prtvtces == 8
replace antielite = 5.4 if prtvtces == 9
replace antielite = 1.8 if prtvtces == 10

*/PSOE
replace incumbent = 1 if prtvtces == 2 & year == 2012
replace election  = 1 if country == 18 & year == 2012
replace pmleft =1 if country == 18 & year == 2012


*/PSOE
replace incumbent = 1 if prtvtces == 2 & year == 2014
replace election  = 1 if country == 18 & year == 2014
replace pmleft =1 if country == 18 & year == 2014

*2016
replace LR = 7.6 if prtvtdes == 1
replace galtan = 8 if prtvtdes == 1
replace LR = 4.1 if prtvtdes == 2
replace galtan = 2.2 if prtvtdes == 2
replace LR = 1.2 if prtvtdes == 3
replace galtan = 1.7 if prtvtdes == 3
replace LR = 1.2 if prtvtdes == 4
replace galtan = 1.7 if prtvtdes == 4
replace LR = 7 if prtvtdes == 5
replace galtan = 3.2 if prtvtdes == 5
replace LR = 1.7 if prtvtdes == 6
replace galtan = 1.3 if prtvtdes == 6
replace LR = 3.6 if prtvtdes == 10
replace galtan = 2.1 if prtvtdes == 10
replace LR = 3.6 if prtvtdes == 15
replace galtan = 5.2 if prtvtdes == 15
replace LR = 3.6 if prtvtdes == 16
replace galtan = 5.2 if prtvtdes == 16

replace cright = 1 if prtvtdes == 1
replace cright = 1 if prtvtdes == 11
replace cright = 1 if prtvtdes == 15
replace cright = 1 if prtvtdes == 16
replace cleft = 1 if prtvtdes == 2
replace cleft = 1 if prtvtdes == 3
replace cleft = 1 if prtvtdes == 4
replace cleft = 1 if prtvtdes == 5
replace cleft = 1 if prtvtdes == 7
replace cleft = 1 if prtvtdes == 8
replace cleft = 1 if prtvtdes == 9
replace cleft = 1 if prtvtdes == 10
replace cleft = 1 if prtvtdes == 12
replace rleft = 1 if prtvtdes == 6

replace antielite = 1.4 if prtvtdes == 1
replace antielite = 3 if prtvtdes == 2
replace antielite = 10 if prtvtdes == 3
replace antielite = 10 if prtvtdes == 4
replace antielite = 6.4 if prtvtdes == 5
replace antielite = 5.5 if prtvtdes == 6
replace antielite = 4.2 if prtvtdes == 10
replace antielite = 1.8 if prtvtdes == 15
replace antielite = 1.8 if prtvtdes == 16

*/PP
replace incumbent = 1 if prtvtdes == 1 & year == 2016
replace election  = 2 if country == 18 & year == 2016
replace pmright =1 if country == 18 & year == 2016


*2018 (under adv)
replace LR = 7.6 if prtvtees == 1
replace galtan = 8 if prtvtees == 1
replace LR = 4.1 if prtvtees == 2
replace galtan = 2.2 if prtvtees == 2
replace LR = 1.2 if prtvtees == 3
replace galtan = 1.7 if prtvtees == 3
replace LR = 1.2 if prtvtees == 4
replace galtan = 1.7 if prtvtees == 4
replace LR = 7 if prtvtees == 5
replace galtan = 3.2 if prtvtees == 5
replace LR = 1.7 if prtvtees == 6
replace galtan = 1.3 if prtvtees == 6
replace LR = 3.6 if prtvtees == 10
replace galtan = 2.1 if prtvtees == 10
replace LR = 2.2 if prtvtees == 12
replace galtan = 1.7 if prtvtees == 12
replace LR = 3.6 if prtvtees == 15
replace galtan = 5.2 if prtvtees == 15

replace cright = 1 if prtvtees == 1
replace cright = 1 if prtvtees == 11
replace cright = 1 if prtvtees == 12
replace cleft = 1 if prtvtees == 2
replace cleft = 1 if prtvtees == 3
replace cleft = 1 if prtvtees == 4
replace cleft = 1 if prtvtees == 5
replace cleft = 1 if prtvtees == 7
replace cleft = 1 if prtvtees == 8
replace cleft = 1 if prtvtees == 9
replace cleft = 1 if prtvtees == 10
replace rleft = 1 if prtvtees == 6
replace rright = 1 if prtvtees == 16

replace antielite = 1.4 if prtvtees == 1
replace antielite = 3 if prtvtees == 2
replace antielite = 10 if prtvtees == 3
replace antielite = 10 if prtvtees == 4
replace antielite = 6.4 if prtvtees == 5
replace antielite = 5.5 if prtvtees == 6
replace antielite = 4.2 if prtvtees == 10
replace antielite = 5.4 if prtvtees == 12
replace antielite = 1.8 if prtvtees == 15

*/PP
replace incumbent = 1 if prtvtees == 1 & year == 2018
replace election  = 2 if country == 18 & year == 2018
replace pmright =1 if country == 18 & year == 2018


***** Sweden ***** 
*2012
replace LR = 7.2 if prtvtbse == 1
replace galtan = 5 if prtvtbse == 1
replace LR = 7.5 if prtvtbse == 2
replace galtan = 3.6 if prtvtbse == 2
replace LR = 3.7 if prtvtbse == 3
replace galtan = 7 if prtvtbse == 3
replace LR = 3.6 if prtvtbse == 4
replace galtan = 2.8 if prtvtbse == 4
replace LR = 7.5 if prtvtbse == 5
replace galtan = 5.2 if prtvtbse == 5
replace LR = 3.4 if prtvtbse == 6
replace galtan = 4.2 if prtvtbse == 6
replace LR = 1.2 if prtvtbse == 7
replace galtan = 3.1 if prtvtbse == 7
replace LR = 6.1 if prtvtbse == 9
replace galtan = 2.1 if prtvtbse == 9
replace LR = 5.5 if prtvtbse == 10
replace galtan = 8.2 if prtvtbse == 10

replace cright = 1 if prtvtbse == 1
replace cright = 1 if prtvtbse == 2
replace cright = 1 if prtvtbse == 3
replace cright = 1 if prtvtbse == 5
replace cright = 1 if prtvtbse == 1
replace cleft = 1 if prtvtbse == 4
replace cleft = 1 if prtvtbse == 6
replace cleft = 1 if prtvtbse == 8
replace rleft = 1 if prtvtbse == 7
replace rright = 1 if prtvtbse == 10

*/coalition Moderate, Centre, liberale & christen democrats
replace incumbent = 1 if prtvtbse == 1 & year == 2012
replace incumbent = 1 if prtvtbse == 2 & year == 2012
replace incumbent = 1 if prtvtbse == 3 & year == 2012
replace incumbent = 1 if prtvtbse == 5 & year == 2012
replace election  = 1 if country == 19 & year == 2012
replace pmright =1 if country == 19 & year == 2012

*2014-2016
replace LR = 7.6 if prtvtbse == 1
replace galtan = 3 if prtvtbse == 1
replace LR = 7.4 if prtvtbse == 2
replace galtan = 3.1 if prtvtbse == 2
replace LR = 7.1 if prtvtbse == 3
replace galtan = 6.9 if prtvtbse == 3
replace LR = 3.5 if prtvtbse == 4
replace galtan = 1.6 if prtvtbse == 4
replace LR = 7.6 if prtvtbse == 5
replace galtan = 4.6 if prtvtbse == 5
replace LR = 5.4 if prtvtbse == 6
replace galtan = 3.6 if prtvtbse == 6
replace LR = 1.3 if prtvtbse == 7
replace galtan = 1.9 if prtvtbse == 7
replace LR = 1.7 if prtvtbse == 8
replace galtan = 0.8 if prtvtbse == 8
replace LR = 5.2 if prtvtbse == 9
replace galtan = 1.2 if prtvtbse == 9
replace LR = 5.4 if prtvtbse == 10
replace galtan = 9.2 if prtvtbse == 10

replace cleft = 1 if prtvtbse == 4
replace cleft = 1 if prtvtbse == 6
replace cleft = 1 if prtvtbse == 8
replace cright = 1 if prtvtbse == 1
replace cright = 1 if prtvtbse == 2
replace cright = 1 if prtvtbse == 3
replace cright = 1 if prtvtbse == 5
replace rleft = 1 if prtvtbse == 7
replace rleft = 1 if prtvtbse == 9
replace rright = 1 if prtvtbse == 10

replace antielite = 2 if prtvtbse == 1
replace antielite = 1.9 if prtvtbse == 2
replace antielite = 2.1 if prtvtbse == 3
replace antielite = 3.5 if prtvtbse == 4
replace antielite = 1.7 if prtvtbse == 5
replace antielite = 1.9 if prtvtbse == 6
replace antielite = 5.3 if prtvtbse == 7
replace antielite = 7.1 if prtvtbse == 8
replace antielite = 8 if prtvtbse == 9
replace antielite = 8.8 if prtvtbse == 10

*/coalition Moderate, Centre, liberale & christen democrats
replace incumbent = 1 if prtvtbse == 1 & year == 2014
replace incumbent = 1 if prtvtbse == 2 & year == 2014
replace incumbent = 1 if prtvtbse == 3 & year == 2014
replace incumbent = 1 if prtvtbse == 5 & year == 2014
replace election  = 2 if country == 19 & year == 2014
replace pmright =1 if country == 19 & year == 2014

*/coalition Moderate, Centre, liberale & christen democrats
replace incumbent = 1 if prtvtbse == 1 & year == 2016
replace incumbent = 1 if prtvtbse == 2 & year == 2016
replace incumbent = 1 if prtvtbse == 3 & year == 2016
replace incumbent = 1 if prtvtbse == 5 & year == 2016
replace election  = 2 if country == 19 & year == 2016
replace pmright =1 if country == 19 & year == 2016

*2018 (advise)
replace LR = 7.6 if prtvtcse == 1
replace galtan = 3 if prtvtcse == 1
replace LR = 7.4 if prtvtcse == 2
replace galtan = 3.1 if prtvtcse == 2
replace LR = 7.1 if prtvtcse == 3
replace galtan = 6.9 if prtvtcse == 3
replace LR = 3.5 if prtvtcse == 4
replace galtan = 1.6 if prtvtcse == 4
replace LR = 7.6 if prtvtcse == 5
replace galtan = 4.6 if prtvtcse == 5
replace LR = 5.4 if prtvtcse == 6
replace galtan = 3.6 if prtvtcse == 6
replace LR = 1.3 if prtvtcse == 7
replace galtan = 1.9 if prtvtcse == 7
replace LR = 1.7 if prtvtcse == 8
replace galtan = 0.8 if prtvtcse == 8
replace LR = 5.4 if prtvtcse == 9
replace galtan = 9.2 if prtvtcse == 9

replace cleft = 1 if prtvtcse == 4
replace cleft = 1 if prtvtcse == 6
replace cleft = 1 if prtvtcse == 8
replace cright = 1 if prtvtcse == 1
replace cright = 1 if prtvtcse == 2
replace cright = 1 if prtvtcse == 3
replace cright = 1 if prtvtcse == 5
replace rleft = 1 if prtvtcse == 7
replace rright = 1 if prtvtcse == 9

replace antielite = 2 if prtvtcse == 1
replace antielite = 1.9 if prtvtcse == 2
replace antielite = 2.1 if prtvtcse == 3
replace antielite = 3.5 if prtvtcse == 4
replace antielite = 1.7 if prtvtcse == 5
replace antielite = 1.9 if prtvtcse == 6
replace antielite = 5.3 if prtvtcse == 7
replace antielite = 7.1 if prtvtcse == 8
replace antielite = 8.8 if prtvtcse == 9

*/coalition Green and social democrats
replace incumbent = 1 if prtvtcse == 4 & year == 2018
replace incumbent = 1 if prtvtcse == 6  & year == 2018
replace election  = 3 if country == 19 & year == 2018
replace pmleft =1 if country == 19 & year == 2018



***** United Kingdom ***** 
*2012
replace LR = 7.6 if prtvtgb == 1 & essround == 6
replace galtan = 6.2 if prtvtgb == 1 & essround == 6
replace LR = 4 if prtvtgb == 2 & essround == 6
replace galtan = 4 if prtvtgb == 2 & essround == 6
replace LR = 5.6 if prtvtgb == 3 & essround == 6
replace galtan = 2.7 if prtvtgb == 3 & essround == 6
replace LR = 2.9 if prtvtgb == 4 & essround == 6
replace galtan = 2.5 if prtvtgb == 4 & essround == 6
replace LR = 2.6 if prtvtgb == 5 & essround == 6
replace galtan = 3.2 if prtvtgb == 5 & essround == 6
replace LR = 1.9 if prtvtgb == 6 & essround == 6
replace galtan = 1.4 if prtvtgb == 6 & essround == 6
replace LR = 5.4 if prtvtgb == 7 & essround == 6
replace galtan = 9.5 if prtvtgb == 7 & essround == 6
replace LR = 8.1 if prtvtgb == 8 & essround == 6
replace galtan = 7.6 if prtvtgb == 8 & essround == 6

*/Labour
replace incumbent = 1 if prtvtgb == 2 & year == 2012
replace election  = 1 if country == 20 & year == 2012
replace pmleft =1 if country == 20 & year == 2012


*2014
replace LR = 7.8 if prtvtbgb == 1 & essround == 7
replace galtan = 6.1 if prtvtbgb == 1 & essround == 7
replace LR = 3.8 if prtvtbgb == 2 & essround == 7
replace galtan = 3.4 if prtvtbgb == 2 & essround == 7
replace LR = 5.1 if prtvtbgb == 3 & essround == 7
replace galtan = 2.4 if prtvtbgb == 3 & essround == 7
replace LR = 3.3 if prtvtbgb == 4 & essround == 7
replace galtan = 4.5 if prtvtbgb == 4 & essround == 7
replace LR = 3.2 if prtvtbgb == 5 & essround == 7
replace galtan = 4.3 if prtvtbgb == 5 & essround == 7
replace LR = 2 if prtvtbgb == 6 & essround == 7
replace galtan = 1 if prtvtbgb == 6 & essround == 7
replace LR = 8.5 if prtvtbgb == 7 & essround == 7
replace galtan = 9.2 if prtvtbgb == 7 & essround == 7


replace cright = 1 if prtvtbgb == 1
replace cright = 1 if prtvtbgb == 3
replace cright = 1 if prtvtbgb == 9
replace cright = 1 if prtvtbgb == 10
replace cleft = 1 if prtvtbgb == 2
replace cleft = 1 if prtvtbgb == 4
replace cleft = 1 if prtvtbgb == 5
replace cleft = 1 if prtvtbgb == 6
replace cleft = 1 if prtvtbgb == 11
replace cleft = 1 if prtvtbgb == 12
replace rright = 1 if prtvtbgb == 7

replace antielite = 2.1 if prtvtbgb == 1
replace antielite = 4 if prtvtbgb == 2
replace antielite = 3.1 if prtvtbgb == 3
replace antielite = 7.3 if prtvtbgb == 4
replace antielite = 6.5 if prtvtbgb == 5
replace antielite = 7.6 if prtvtbgb == 6
replace antielite = 9.2 if prtvtbgb == 7

*/Conservative and Libdem
replace incumbent = 1 if prtvtbgb == 1 & year == 2014
replace incumbent = 1 if prtvtbgb == 3 & year == 2014
replace election  = 2 if country == 20 & year == 2014
replace pmright =1 if country == 20 & year == 2014

*2016
replace LR = 7.8 if prtvtbgb == 1 & essround == 8
replace galtan = 6.1 if prtvtbgb == 1 & essround == 8
replace LR = 3.8 if prtvtbgb == 2 & essround == 8
replace galtan = 3.4 if prtvtbgb == 2 & essround == 8
replace LR = 5.1 if prtvtbgb == 3 & essround == 8
replace galtan = 2.4 if prtvtbgb == 3 & essround == 8
replace LR = 3.3 if prtvtbgb == 4 & essround == 8
replace galtan = 4.5 if prtvtbgb == 4 & essround == 8
replace LR = 3.2 if prtvtbgb == 5 & essround == 8
replace galtan = 4.3 if prtvtbgb == 5 & essround == 8
replace LR = 2 if prtvtbgb == 6 & essround == 8
replace galtan = 1 if prtvtbgb == 6 & essround == 8
replace LR = 8.5 if prtvtbgb == 7 & essround == 8
replace galtan = 9.2 if prtvtbgb == 7 & essround == 8

*/Conservative 
replace incumbent = 1 if prtvtbgb == 1 & year == 2016
replace election  = 3 if country == 20 & year == 2016
replace pmright =1 if country == 20 & year == 2016

*2018 (advise)
replace LR = 7.8 if prtvtcgb == 1
replace galtan = 6.1 if prtvtcgb == 1 
replace LR = 3.8 if prtvtcgb == 2
replace galtan = 3.4 if prtvtcgb == 2 
replace LR = 5.1 if prtvtcgb == 3
replace galtan = 2.4 if prtvtcgb == 3
replace LR = 3.3 if prtvtcgb == 4 
replace galtan = 4.5 if prtvtcgb == 4 
replace LR = 3.2 if prtvtcgb == 5 
replace galtan = 4.3 if prtvtcgb == 5 
replace LR = 2 if prtvtcgb == 6 
replace galtan = 1 if prtvtcgb == 6 
replace LR = 8.5 if prtvtcgb == 7 
replace galtan = 9.2 if prtvtcgb == 7  

replace cright = 1 if prtvtcgb == 1
replace cright = 1 if prtvtcgb == 3
replace cright = 1 if prtvtcgb == 9
replace cright = 1 if prtvtcgb == 10
replace cleft = 1 if prtvtcgb == 2
replace cleft = 1 if prtvtcgb == 4
replace cleft = 1 if prtvtcgb == 5
replace cleft = 1 if prtvtcgb == 6
replace cleft = 1 if prtvtcgb == 11
replace cleft = 1 if prtvtcgb == 12
replace cleft = 1 if prtvtcgb == 15
replace rright = 1 if prtvtcgb == 7


*/Conservative 
replace incumbent = 1 if prtvtcgb == 1 & year == 2018
replace election  = 3 if country == 20 & year == 2018
replace pmright =1 if country == 20 & year == 2018


}

* ENDCODE Parties
gen radical = 0
replace radical = 1 if rleft == 1 
replace radical = 1 if rright == 1
gen centre =.
replace centre = 1 if radical ==0
replace centre = 0 if radical == 1

gen Radical =1
replace Radical =2 if rleft == 1
replace Radical =3 if rright == 1
replace Radical =4 if vote == 2

gen Radical2 =.
replace Radical2 =1 if cright == 1
replace Radical2 =2 if cleft == 1
replace Radical2 =3 if rright  == 1
replace Radical2 =4 if rleft == 1
replace Radical2 =5 if vote == 2

gen abstain =.
replace abstain=0 if Radical2 <5
replace abstain=1 if vote ==2

replace LR = . if refusal == 1 
replace galtan = . if refusal == 1 
replace LR = . if unknown == 1 
replace galtan = . if unknown == 1 
replace antielite = . if refusal == 1
replace antielite = . if unknown == 1

replace rright =0 if rright ==.
replace cleft =0 if cleft ==.
replace rleft =0 if rleft ==.
replace cright =0 if cright ==.

gen leftincumb=0
replace leftincumb =1 if incumbent ==1 & pmleft ==1
gen rightincumb=0
replace rightincumb =1  if incumbent ==1 & pmright ==1


*****************************************************
*********************** 2. Sector *******************
*****************************************************
*/ I standardise the sector of occupation from NACE rev1 (and 1.1) 
*/ using * https://ec.europa.eu/eurostat/documents/1965800/1978760/CORRESPONDENCETABLENACEREV.2NACE-REV.1.1.pdf/df9cd8a8-0b4a-4197-bad7-727a0b9fd59b
*/ below is a best aproximate standardisation
*/ the absence of 3-4 digit NACE info means some sectors need to be aggregated together

gen  sectorunknown = 0
foreach var of varlist nacer1-nacer2{
replace sectorunknown = 1 if `var' == .a
replace sectorunknown = 1 if `var' == .b
replace sectorunknown = 1 if `var' == .c
replace sectorunknown = 1 if `var' == .d

}

{
drop Sector
gen Sector = .
replace Sector = 1 if nacer2 == 1
replace Sector = 1 if nacer1 == 1
replace Sector = 1 if nacer11 == 1
replace Sector = 2 if nacer2 == 2
replace Sector = 2 if nacer1 == 2
replace Sector = 2 if nacer11 == 2
replace Sector = 3 if nacer2 == 3
replace Sector = 3 if nacer1 == 5
replace Sector = 3 if nacer11 == 5
replace Sector = 5 if nacer2 == 5
replace Sector = 5 if nacer2 == 6
replace Sector = 5 if nacer2 == 7
replace Sector = 5 if nacer2 == 8
replace Sector = 5 if nacer2 == 9
replace Sector = 5 if nacer1 == 10
replace Sector = 5 if nacer1 == 11
replace Sector = 5 if nacer1 == 12
replace Sector = 5 if nacer1 == 13
replace Sector = 5 if nacer1 == 14
replace Sector = 5 if nacer11 == 10
replace Sector = 5 if nacer11 == 11
replace Sector = 5 if nacer11 == 12
replace Sector = 5 if nacer11 == 13
replace Sector = 5 if nacer11 == 14
replace Sector = 6 if nacer2 == 10
replace Sector = 6 if nacer2 == 11
replace Sector = 6 if nacer1 == 15
replace Sector = 6 if nacer11 == 15
replace Sector = 7 if nacer2 == 12
replace Sector = 7 if nacer1 == 16
replace Sector = 7 if nacer11 == 16
replace Sector = 8 if nacer2 == 13
replace Sector = 8 if nacer2 == 14
replace Sector = 8 if nacer2 == 15
replace Sector = 8 if nacer1 == 17
replace Sector = 8 if nacer1 == 18
replace Sector = 8 if nacer1 == 19
replace Sector = 8 if nacer11 == 17
replace Sector = 8 if nacer11 == 18
replace Sector = 8 if nacer11 == 19
replace Sector = 9 if nacer2 == 16
replace Sector = 9 if nacer2 == 17
replace Sector = 9 if nacer1 == 20
replace Sector = 9 if nacer1 == 21
replace Sector = 9 if nacer11 == 20
replace Sector = 9 if nacer11 == 21
replace Sector = 10 if nacer2 == 19
replace Sector = 10 if nacer2 == 20
replace Sector = 10 if nacer2 == 21
replace Sector = 10 if nacer2 == 22
replace Sector = 10 if nacer1 == 23
replace Sector = 10 if nacer1 == 24
replace Sector = 10 if nacer1 == 25
replace Sector = 10 if nacer11 == 23
replace Sector = 10 if nacer11 == 24
replace Sector = 10 if nacer11 == 25
replace Sector = 11 if nacer2 == 23
replace Sector = 11 if nacer1 == 26
replace Sector = 11 if nacer11 == 26
replace Sector = 12 if nacer2 == 24
replace Sector = 12 if nacer2 == 25
replace Sector = 12 if nacer1 == 27
replace Sector = 12 if nacer1 == 28
replace Sector = 12 if nacer11 == 27
replace Sector = 12 if nacer11 == 28
replace Sector = 13 if nacer2 == 26
replace Sector = 13 if nacer2 == 27
replace Sector = 13 if nacer1 == 30
replace Sector = 13 if nacer1 == 31
replace Sector = 13 if nacer1 == 32
replace Sector = 13 if nacer1 == 33
replace Sector = 13 if nacer11 == 30
replace Sector = 13 if nacer11 == 31
replace Sector = 13 if nacer11 == 32
replace Sector = 13 if nacer11 == 33
replace Sector = 14 if nacer2 == 28
replace Sector = 14 if nacer1 == 29
replace Sector = 14 if nacer11 == 29
replace Sector = 15 if nacer2 == 29
replace Sector = 15 if nacer2 == 30
replace Sector = 15 if nacer1 == 34
replace Sector = 15 if nacer1 == 35
replace Sector = 15 if nacer11 == 34
replace Sector = 15 if nacer11 == 35
replace Sector = 16 if nacer2 == 31
replace Sector = 16 if nacer2 == 32
replace Sector = 16 if nacer2 == 33
replace Sector = 16 if nacer1 == 36
replace Sector = 16 if nacer11 == 36
replace Sector = 17 if nacer2 == 35
replace Sector = 17 if nacer2 == 36
replace Sector = 17 if nacer1 == 40
replace Sector = 17 if nacer1 == 41
replace Sector = 17 if nacer11 == 40
replace Sector = 17 if nacer11 == 41
replace Sector = 18 if nacer2 == 37
replace Sector = 18 if nacer1 == 90
replace Sector = 18 if nacer11 == 90
replace Sector = 19 if nacer2 == 38
replace Sector = 19 if nacer2 == 39
replace Sector = 19 if nacer1 == 37
replace Sector = 19 if nacer11 == 37
replace Sector = 20 if nacer2 == 41
replace Sector = 20 if nacer2 == 42
replace Sector = 20 if nacer2 == 43
replace Sector = 20 if nacer1 == 45
replace Sector = 20 if nacer11 == 45
replace Sector = 21 if nacer2 == 45
replace Sector = 21 if nacer1 == 50
replace Sector = 21 if nacer11 == 50
replace Sector = 22 if nacer2 == 46
replace Sector = 22 if nacer1 == 51
replace Sector = 22 if nacer11 == 51
replace Sector = 23 if nacer2 == 47
replace Sector = 23 if nacer1 == 52
replace Sector = 23 if nacer11 == 52
replace Sector = 24 if nacer2 == 49
replace Sector = 24 if nacer1 == 60
replace Sector = 24 if nacer11 == 60
replace Sector = 25 if nacer2 == 50
replace Sector = 25 if nacer1 == 61
replace Sector = 25 if nacer1 == 61
replace Sector = 26 if nacer2 == 51
replace Sector = 26 if nacer1 == 62
replace Sector = 26 if nacer11 == 62
replace Sector = 27 if nacer2 == 52
replace Sector = 27 if nacer2 == 79
replace Sector = 27 if nacer1 == 63
replace Sector = 27 if nacer11 == 63
replace Sector = 28 if nacer2 == 53
replace Sector = 28 if nacer2 == 60
replace Sector = 28 if nacer2 == 61
replace Sector = 28 if nacer1 == 64
replace Sector = 28 if nacer11 == 64
replace Sector = 29 if nacer2 == 55
replace Sector = 29 if nacer2 == 56
replace Sector = 29 if nacer1 == 55
replace Sector = 29 if nacer1 == 55
replace Sector = 30 if nacer2 == 18
replace Sector = 30 if nacer2 == 58
replace Sector = 30 if nacer1 == 22
replace Sector = 30 if nacer11 == 22
replace Sector = 31 if nacer2 == 59
replace Sector = 31 if nacer2 == 91
replace Sector = 31 if nacer2 == 92
replace Sector = 31 if nacer2 == 93
replace Sector = 31 if nacer1 == 92
replace Sector = 31 if nacer11 == 92
replace Sector = 32 if nacer2 == 62
replace Sector = 32 if nacer2 == 63
replace Sector = 32 if nacer1 == 72
replace Sector = 32 if nacer11 == 72
replace Sector = 33 if nacer2 == 64
replace Sector = 33 if nacer1 == 65
replace Sector = 33 if nacer11 == 65
replace Sector = 34 if nacer2 == 65
replace Sector = 34 if nacer1 == 66
replace Sector = 34 if nacer11 == 66
replace Sector = 35 if nacer2 == 66
replace Sector = 35 if nacer1 == 67
replace Sector = 35 if nacer11 == 67
replace Sector = 36 if nacer2 == 68
replace Sector = 36 if nacer1 == 70
replace Sector = 36 if nacer11 == 70
replace Sector = 37 if nacer2 == 69
replace Sector = 37 if nacer2 == 70
replace Sector = 37 if nacer2 == 71
replace Sector = 37 if nacer2 == 74
replace Sector = 37 if nacer2 == 73
replace Sector = 37 if nacer1 == 78
replace Sector = 37 if nacer2 == 80
replace Sector = 37 if nacer2 == 81
replace Sector = 37 if nacer2 == 82
replace Sector = 37 if nacer1 == 74
replace Sector = 37 if nacer11 == 74
replace Sector = 38 if nacer2 == 72
replace Sector = 38 if nacer1 == 73
replace Sector = 38 if nacer11 == 73
replace Sector = 39 if nacer2 == 75
replace Sector = 39 if nacer2 == 85
replace Sector = 39 if nacer2 == 87
replace Sector = 39 if nacer2 == 88
replace Sector = 39 if nacer1 == 85
replace Sector = 39 if nacer11 == 85
replace Sector = 40 if nacer2 == 77
replace Sector = 40 if nacer1 == 71
replace Sector = 40 if nacer11 == 71
replace Sector = 41 if nacer2 == 84
replace Sector = 41 if nacer1 == 75
replace Sector = 41 if nacer11 == 75
replace Sector = 42 if nacer2 == 86
replace Sector = 42 if nacer1 == 80
replace Sector = 42 if nacer11 == 80
replace Sector = 43 if nacer2 == 94
replace Sector = 43 if nacer1 == 91
replace Sector = 43 if nacer11 == 91
replace Sector = 44 if nacer2 == 99
replace Sector = 44 if nacer1 == 99
replace Sector = 44 if nacer11 == 99
replace Sector = 45 if nacer2 == 96
replace Sector = 45 if nacer1 == 93
replace Sector = 45 if nacer11 == 93
}


* Dropping various household activities
drop if nacer2 == 97
drop if nacer2 == 98
drop if nacer1 == 95
drop if nacer1 == 96
drop if nacer1 == 97
drop if nacer11 == 95
drop if nacer11 == 96
drop if nacer11 == 97

* Labeling sectors

label define Sector 1 "Agriculture" 2 "Forestry and logging" 3 "Fishing and aquaculture" 5 "Mining and quarrying" 6 "Manufacture of food and beverages" ///
7 "Manufacture of tobacco products" 8 "Manufacture of textiles, clothing and leather" 9 "Manufacture of wood, paper and printing" 10 "Manufacture of plastics, chemicals and pharmaceuticals" ///
11 "Manufacture of non-metallic mineral products" 12 "Manufacture of basic metals and fabricated metal products" 13 "Manufacture of electronics and optical equipment" ///
14 "Manufacture of machinery and equipment" 15 "Manufacture of vehicles and other transport equipment" 16 "Manufacture of furniture and other" ///
17 "Energy and water supply"  18 "Sewerage" 19 "Waste collection, waste management and recycling" 20 "Construction and civil engineering" 21 "Trade and repair of motor vehicles" ///
22 "Wholesale trade (excl. motor vehicles)" 23 "Retail trade (excl. motor vehicles)" 24 "Land transport and transport via pipelines" 25 "Water transport" 26 "Air transport" ///
27 "Warehousing and support activities for transportation" 28 "Post and telecommunications" 29 "Hotels, restaurants and bars" 30 "Publishing" ///
31 "Recreational, cultural and sporting activities" 32 "Computer programming and information service activities" 33 "Financial services (excl. insurance)" ///
34 "Insurance, reinsurance and pension funding (excl. compulsary social insurance)" 35 "Auxilirary financial services and insurance activities" ///
36 "Real estate activities" 37 "General business activities" 38 "Scientific research and development" 39 "Health and social work" 40 "Rental and leasing activities" ///
41 "Public administration and de fence" 42 "Education" 43 "Activities of membership organisations" 44 "Activities of extraterritorial organisations and bodies" ///
45 "Other services"
label values Sector Sector

*/coding dummies for key sectors of the economy
gen Primary = 0 
replace Primary = 1 if Sector < 6
gen Secondary = 0 
replace Secondary = 1 if Sector  > 5
replace Secondary = 0 if Sector > 16
gen Tertiary = 0
replace Tertiary = 1 if Sector > 16

*****************************************************
*********************** 3. Occupations **************
*****************************************************

*** This is the code from Harry Ganzeboom to convert occupations from ISCO-88 to ISCO
list cntry essround iscoco if iscoco<100
replace iscoco=99999 if iscoco<100
list cntry essround iscoco if iscoco>100 & iscoco<1000
list cntry essround iscocop if iscocop<100
list cntry essround iscocop if iscocop>100 & iscocop<1000
list cntry essround isco08 if isco08<1000 & !inlist(isco08,0,100,110,200,210,300,310)
list cntry essround isco08p if isco08p<1000 & !inlist(isco08p,0,100,110,200,210,300,310)


  
 *A.2 Frey and Osborne (2017) adapted from Pajarinen and Rouvinen (2014	
	
// Automation (F&B)
{
*replace iscoco=0 if isco08==9999
replace isco08=110 if iscoco==110
replace isco08=210 if iscoco==210
replace isco08=310 if iscoco==110
replace isco08=10 if iscoco==1100
replace isco08=200 if iscoco==120
replace isco08=300 if iscoco==100
replace isco08=1000 if iscoco==1000
replace isco08=1100 if iscoco==1100
replace isco08=1100 if iscoco==1110
replace isco08=1111 if iscoco==1110
replace isco08=1112 if iscoco==1120
replace isco08=1113 if iscoco==1130
replace isco08=1114 if iscoco==1140
replace isco08=1120 if iscoco==1210
replace isco08=1200 if iscoco==1200
replace isco08=1210 if iscoco==1230
replace isco08=1211 if iscoco==1231
replace isco08=1212 if iscoco==1232
replace isco08=1213 if iscoco==1239
replace isco08=1219 if iscoco==1229
replace isco08=1220 if iscoco==1230
replace isco08=1221 if iscoco==1233
replace isco08=1222 if iscoco==1234
replace isco08=1223 if iscoco==1237
replace isco08=1300 if iscoco==1220
replace isco08=1310 if iscoco==1221
replace isco08=1311 if iscoco==1211
replace isco08=1321 if iscoco==1221
replace isco08=1320 if iscoco==1220
replace isco08=1321 if iscoco==1222
replace isco08=1322 if iscoco==1222
replace isco08=1323 if iscoco==1223
replace isco08=1324 if iscoco==1235
replace isco08=1330 if iscoco==1236
replace isco08=1340 if iscoco==1229
replace isco08=1341 if iscoco==1229
replace isco08=1342 if iscoco==1229
replace isco08=1343 if iscoco==1229
replace isco08=1344 if iscoco==1229
replace isco08=1345 if iscoco==1229
replace isco08=1346 if iscoco==1227
replace isco08=1349 if iscoco==1229
replace isco08=1400 if iscoco==1310
replace isco08=1410 if iscoco==1310
replace isco08=1411 if iscoco==1315
replace isco08=1412 if iscoco==1315
replace isco08=1420 if iscoco==1314
replace isco08=1430 if iscoco==1319
replace isco08=1431 if iscoco==1319
replace isco08=1439 if iscoco==1319
replace isco08=2000 if iscoco==2000
replace isco08=2100 if iscoco==2100
replace isco08=2110 if iscoco==2110
replace isco08=2111 if iscoco==2111
replace isco08=2112 if iscoco==2112
replace isco08=2113 if iscoco==2113
replace isco08=2114 if iscoco==2114
replace isco08=2120 if iscoco==2120
replace isco08=2210 if iscoco==2130
replace isco08=2231 if iscoco==2211
replace isco08=2232 if iscoco==2213
replace isco08=2133 if iscoco==2200
replace isco08=2140 if iscoco==2140
replace isco08=2141 if iscoco==2149
replace isco08=2142 if iscoco==2142
replace iscoco=2143 if iscoco==2149
replace isco08=2144 if iscoco==2145
replace isco08=2145 if iscoco==2146
replace isco08=2146 if iscoco==2147
replace isco08=2149 if iscoco==2149
replace isco08=2150 if iscoco==2140
replace iscoco=2151 if iscoco==2143
replace isco08=2152 if iscoco==2144
replace isco08=2153 if iscoco==2144
replace isco08=2160 if iscoco==2140
replace isco08=2161 if iscoco==2141
replace isco08=2162 if iscoco==2141
replace isco08=2163 if iscoco==3471
replace isco08=2164 if iscoco==2141
replace isco08=2165 if iscoco==2148
replace isco08=2166 if iscoco==3471
replace isco08=2200 if iscoco==2200
replace isco08=2220 if iscoco==2210
replace isco08=2221 if iscoco==2211
replace isco08=2212 if iscoco==2221
replace isco08=2230 if iscoco==2230
replace isco08=2221 if iscoco==2230
replace isco08=2222 if iscoco==2230
replace isco08=2230 if iscoco==3229
replace isco08=2240 if iscoco==3221
replace isco08=2250 if iscoco==2223
replace isco08=2260 if iscoco==3210
replace isco08=2261 if iscoco==2222
replace isco08=2262 if iscoco==2224
replace isco08=2263 if iscoco==2229
replace isco08=2264 if iscoco==3226
replace isco08=2265 if iscoco==3223
replace isco08=2266 if iscoco==3229
replace isco08=2267 if iscoco==3224
replace isco08=2269 if iscoco==2229
replace iscoco=2310 if iscoco==2310
replace isco08=2320 if iscoco==2320
replace isco08=2330 if iscoco==2320
replace isco08=2300 if iscoco==2300
replace isco08=2340 if iscoco==2330
replace isco08=2341 if iscoco==2331
replace isco08=2342 if iscoco==2352
replace isco08=2350 if iscoco==2350
replace isco08=2351 if iscoco==2351
replace isco08=2351 if iscoco==2352
replace isco08=2352 if iscoco==2350
replace isco08=2353 if iscoco==2359
replace isco08=2354 if iscoco==2359
replace isco08=2355 if iscoco==2359
replace isco08=2356 if iscoco==2359
replace isco08=2359 if iscoco==2359
replace isco08=2400 if iscoco==2400
replace isco08=2410 if iscoco==2410
replace isco08=2411 if iscoco==2411
replace isco08=2412 if iscoco==2419
replace isco08=2413 if iscoco==2419
replace isco08=2420 if iscoco==2419
replace isco08=2421 if iscoco==2420
replace isco08=2422 if iscoco==2419
replace isco08=2423 if iscoco==2412
replace isco08=2424 if iscoco==2423
replace isco08=2430 if iscoco==2410
replace isco08=2431 if iscoco==2419
replace isco08=2432 if iscoco==2419
replace isco08=3433 if iscoco==2415
replace isco08=3434 if iscoco==2415
replace isco08=2500 if iscoco==2100
replace isco08=2510 if iscoco==2130
replace isco08=2511 if iscoco==2131
replace isco08=2512 if iscoco==2131
replace isco08=2513 if iscoco==2131
replace isco08=2513 if iscoco==2139
replace isco08=2514 if iscoco==2132
replace isco08=2519 if iscoco==2131
replace isco08=2520 if iscoco==2131
replace isco08=2521 if iscoco==2131
replace isco08=2522 if iscoco==2131
replace isco08=2523 if iscoco==2131
replace isco08=2529 if iscoco==2139
replace isco08=2600 if iscoco==2400
replace isco08=2610 if iscoco==2420
replace isco08=2611 if iscoco==2421
replace isco08=2612 if iscoco==2422
replace isco08=2619 if iscoco==2429
replace isco08=2620 if iscoco==2430
replace isco08=2621 if iscoco==2431
replace isco08=2622 if iscoco==2432
replace isco08=2630 if iscoco==2440
replace isco08=2631 if iscoco==2441
replace isco08=2632 if iscoco==2442
replace isco08=2633 if iscoco==2443
replace isco08=2634 if iscoco==2445
replace isco08=2635 if iscoco==2446
replace isco08=2636 if iscoco==2460
replace isco08=2640 if iscoco==2450
replace isco08=2641 if iscoco==2451
replace isco08=2642 if iscoco==2451
replace isco08=2643 if iscoco==2444
replace isco08=2650 if iscoco==2450
replace isco08=2651 if iscoco==2452
replace isco08=2652 if iscoco==2453
replace isco08=2653 if iscoco==2454
replace isco08=2654 if iscoco==2455
replace isco08=2655 if iscoco==2455
replace isco08=2656 if iscoco==3472
replace isco08=2659 if iscoco==3474
replace isco08=3000 if iscoco==3000
replace isco08=3100 if iscoco==3100
replace isco08=3110 if iscoco==3110
replace isco08=3111 if iscoco==3111
replace isco08=3112 if iscoco==3112
replace isco08=3113 if iscoco==3113
replace isco08=3114 if iscoco==3114
replace isco08=3115 if iscoco==3115
replace isco08=3116 if iscoco==3116
replace isco08=3117 if iscoco==3117
replace isco08=3118 if iscoco==3118
replace isco08=3119 if iscoco==3119
replace isco08=1220 if iscoco==3120
replace isco08=1229 if iscoco==3120
replace isco08=1222 if iscoco==3122
replace isco08=3123 if iscoco==1223
replace isco08=3130 if iscoco==8160
replace isco08=3131 if iscoco==8161
replace isco08=3132 if iscoco==8163
replace isco08=3133 if iscoco==8150
replace isco08=3143 if iscoco==8155
replace isco08=3135 if iscoco==8120
replace isco08=3139 if iscoco==8290
replace isco08=3140 if iscoco==3210
replace isco08=3141 if iscoco==3211
replace isco08=3142 if iscoco==3212
replace isco08=3143 if iscoco==3212
replace isco08=3150 if iscoco==3140
replace isco08=3151 if iscoco==3141
replace isco08=3152 if iscoco==3142
replace isco08=3153 if iscoco==3143
replace isco08=3154 if iscoco==3144
replace isco08=3155 if iscoco==3145
replace isco08=3200 if iscoco==3100
replace isco08=3210 if iscoco==3130
replace isco08=3211 if iscoco==3133
replace isco08=3212 if iscoco==3211
replace isco08=3213 if iscoco==3228
replace isco08=3214 if iscoco==7311
replace isco08=3220 if iscoco==3230
replace isco08=3221 if iscoco==3231
replace isco08=3232 if iscoco==3242
replace isco08=3230 if iscoco==3241
replace isco08=3240 if iscoco==3227
replace isco08=3250 if iscoco==3220
replace isco08=3251 if iscoco==3225
replace isco08=3252 if iscoco==3229
replace isco08=3253 if iscoco==3229
replace isco08=3254 if iscoco==3224
replace isco08=3255 if iscoco==3226
replace isco08=3256 if iscoco==3221
replace isco08=3257 if iscoco==3152
replace isco08=3258 if iscoco==3152
replace isco08=3259 if iscoco==3229
replace isco08=3300 if iscoco==3300
replace isco08=3310 if iscoco==3410
replace isco08=3311 if iscoco==3411
replace isco08=3312 if iscoco==3419
replace isco08=3313 if iscoco==3433
replace isco08=3314 if iscoco==3434
replace isco08=3315 if iscoco==3417
replace isco08=3320 if iscoco==3410
replace isco08=3321 if iscoco==3412
replace isco08=3322 if iscoco==3415
replace isco08=3323 if iscoco==3416
replace isco08=3324 if iscoco==3421
replace isco08=3330 if iscoco==3420
replace isco08=3331 if iscoco==3422
replace isco08=3332 if iscoco==3414
replace isco08=3332 if iscoco==3439
replace isco08=3333 if iscoco==3423
replace isco08=3334 if iscoco==3413
replace isco08=3339 if iscoco==3429
replace isco08=3340 if iscoco==3430
replace isco08=3341 if iscoco==3431
replace isco08=3342 if iscoco==3431
replace isco08=3343 if iscoco==3431
replace isco08=3344 if iscoco==3431
replace isco08=3350 if iscoco==3440
replace isco08=3351 if iscoco==3441
replace isco08=3352 if iscoco==3442
replace isco08=3353 if iscoco==3443
replace isco08=3354 if iscoco==3444
replace isco08=3355 if iscoco==3450
replace isco08=3359 if iscoco==3449
replace isco08=3400 if iscoco==3400
replace isco08=3410 if iscoco==3430
replace isco08=3411 if iscoco==3432
replace isco08=3412 if iscoco==3460
replace isco08=3413 if iscoco==3480
replace isco08=3420 if iscoco==3470
replace isco08=3421 if iscoco==3475
replace isco08=3422 if iscoco==3475
replace isco08=3423 if iscoco==3340
replace isco08=3423 if iscoco==3475
replace isco08=3430 if iscoco==3470
replace isco08=3431 if iscoco==3131
replace isco08=3432 if iscoco==3471
replace isco08=3433 if iscoco==3470
replace isco08=3434 if iscoco==5122
replace isco08=3435 if iscoco==3470
replace isco08=3500 if iscoco==3100
replace isco08=3510 if iscoco==3120
replace isco08=3511 if iscoco==3122
replace isco08=3512 if iscoco==3121
replace isco08=3513 if iscoco==2139
replace isco08=3514 if iscoco==3121
replace isco08=3520 if iscoco==3130
replace isco08=3521 if iscoco==3130
replace isco08=3522 if iscoco==3114
replace isco08=3522 if iscoco==3132
replace isco08=4000 if iscoco==4000
replace isco08=4110 if iscoco==4100
replace isco08=4120 if iscoco==4115
replace isco08=4100 if iscoco==4100
replace isco08=4130 if iscoco==4110
replace isco08=4131 if iscoco==4112
replace isco08=4132 if iscoco==4113
replace isco08=4200 if iscoco==4200
replace isco08=4210 if iscoco==4210
replace isco08=4211 if iscoco==4211
replace isco08=4212 if iscoco==4213
replace isco08=4213 if iscoco==4214
replace isco08=4214 if iscoco==4215
replace isco08=4220 if iscoco==4220
replace isco08=4221 if iscoco==3414
replace isco08=4222 if iscoco==4222
replace isco08=4223 if iscoco==4223
replace isco08=4224 if iscoco==4222
replace isco08=4225 if iscoco==4222
replace isco08=4226 if iscoco==4222
replace isco08=4227 if iscoco==4190
replace isco08=4229 if iscoco==4222
replace isco08=4300 if iscoco==4100
replace isco08=4310 if iscoco==4120
replace isco08=4311 if iscoco==4121
replace isco08=4312 if iscoco==4122
replace isco08=4313 if iscoco==4121
replace isco08=4320 if iscoco==4130
replace isco08=4321 if iscoco==4131
replace isco08=4322 if iscoco==4132
replace isco08=4323 if iscoco==4133
replace isco08=4400 if iscoco==4400
replace isco08=4410 if iscoco==4140
replace isco08=4411 if iscoco==4141
replace isco08=4412 if iscoco==4142
replace isco08=4413 if iscoco==4143
replace isco08=4414 if iscoco==4144
replace isco08=4415 if iscoco==4141
replace isco08=4416 if iscoco==4190
replace isco08=4419 if iscoco==4190
replace isco08=5000 if iscoco==5000
replace isco08=5100 if iscoco==5100
replace isco08=5110 if iscoco==5110
replace isco08=5111 if iscoco==5111
replace isco08=5112 if iscoco==5112
replace isco08=5113 if iscoco==5113
replace isco08=5120 if iscoco==5122
replace isco08=5130 if iscoco==5120
replace isco08=5131 if iscoco==5123
replace isco08=5132 if iscoco==5123
replace isco08=5140 if iscoco==5140
replace isco08=5141 if iscoco==5141
replace isco08=5142 if iscoco==5141
replace isco08=5150 if iscoco==5120
replace isco08=5151 if iscoco==5121
replace isco08=5152 if iscoco==5121
replace isco08=9153 if iscoco==5141
replace isco08=5160 if iscoco==5140
replace isco08=5161 if iscoco==5152
replace isco08=5162 if iscoco==5142
replace isco08=5163 if iscoco==5143
replace isco08=5164 if iscoco==5149
replace isco08=5165 if iscoco==3340
replace isco08=5169 if iscoco==5149
replace isco08=5200 if iscoco==5200
replace isco08=5210 if iscoco==5230
replace isco08=5211 if iscoco==5230
replace isco08=5212 if iscoco==9111
replace isco08=5222 if iscoco==1314
replace isco08=5521 if iscoco==1314
replace isco08=5222 if iscoco==1314
replace isco08=5223 if iscoco==5220
replace isco08=5230 if iscoco==4211
replace isco08=5240 if iscoco==5230
replace isco08=5241 if iscoco==5210
replace isco08=5242 if iscoco==5220
replace isco08=5243 if iscoco==9113
replace isco08=5444 if iscoco==9113
replace isco08=5245 if iscoco==5220
replace isco08=5246 if iscoco==5123
replace isco08=5249 if iscoco==5220
replace isco08=5300 if iscoco==5100
replace isco08=5310 if iscoco==5130
replace isco08=5311 if iscoco==5131
replace isco08=5312 if iscoco==5131
replace isco08=5320 if iscoco==5130
replace isco08=5321 if iscoco==5132
replace isco08=5322 if iscoco==5133
replace isco08=5329 if iscoco==5139
replace isco08=5400 if iscoco==5100
replace isco08=5410 if iscoco==5160
replace isco08=5411 if iscoco==5161
replace isco08=5412 if iscoco==5162
replace isco08=5413 if iscoco==5163
replace isco08=5414 if iscoco==5169
replace isco08=5419 if iscoco==5169
replace isco08=6000 if iscoco==6000
replace isco08=6100 if iscoco==6100
replace isco08=6110 if iscoco==6110
replace isco08=6111 if iscoco==6111
replace isco08=6112 if iscoco==6112
replace isco08=6113 if iscoco==6113
replace isco08=6114 if iscoco==6114
replace isco08=6120 if iscoco==6120
replace isco08=6121 if iscoco==6124
replace isco08=6122 if iscoco==6122
replace isco08=6123 if iscoco==6123
replace isco08=6129 if iscoco==6129
replace isco08=6130 if iscoco==6130
replace isco08=6210 if iscoco==6141
replace isco08=6200 if iscoco==6150
replace isco08=6220 if iscoco==6150
replace isco08=6221 if iscoco==6151
replace isco08=6222 if iscoco==6152
replace isco08=6223 if iscoco==6153
replace isco08=6224 if iscoco==6154
replace isco08=6300 if iscoco==6200
replace isco08=6310 if iscoco==6210
replace isco08=6320 if iscoco==6210
replace isco08=6330 if iscoco==6210
replace isco08=6340 if iscoco==6210
replace isco08=7000 if iscoco==7000
replace isco08=7100 if iscoco==7100
replace isco08=7110 if iscoco==7120
replace isco08=7111 if iscoco==7129
replace isco08=7112 if iscoco==7122
replace isco08=7113 if iscoco==7113
replace isco08=7114 if iscoco==7123
replace isco08=7115 if iscoco==7124
replace isco08=7119 if iscoco==7129
replace isco08=7120 if iscoco==7130
replace isco08=7121 if iscoco==7131
replace isco08=7122 if iscoco==7132
replace isco08=7123 if iscoco==7133
replace isco08=7124 if iscoco==7134
replace isco08=7125 if iscoco==7135
replace isco08=7126 if iscoco==7136
replace isco08=7127 if iscoco==7127
replace isco08=7130 if iscoco==7140
replace isco08=7131 if iscoco==7141
replace isco08=7132 if iscoco==7142
replace isco08=7133 if iscoco==7143
replace isco08=7200 if iscoco==7200
replace isco08=7210 if iscoco==7210
replace isco08=7211 if iscoco==7211
replace isco08=7212 if iscoco==7212
replace isco08=7213 if iscoco==7213
replace isco08=7214 if iscoco==7214
replace isco08=7215 if iscoco==7215
replace isco08=7220 if iscoco==7220
replace isco08=7221 if iscoco==7221
replace isco08=7222 if iscoco==7222
replace isco08=7223 if iscoco==7223
replace isco08=7224 if iscoco==7224
replace isco08=7230 if iscoco==7230
replace isco08=7231 if iscoco==7231
replace isco08=7232 if iscoco==7232
replace isco08=7233 if iscoco==7233
replace isco08=7234 if iscoco==7231
replace isco08=7300 if iscoco==7300
replace isco08=7310 if iscoco==7310
replace isco08=7311 if iscoco==7311
replace isco08=7312 if iscoco==7312
replace isco08=7313 if iscoco==7313
replace isco08=7314 if iscoco==7321
replace isco08=7315 if iscoco==7322
replace isco08=7316 if iscoco==3471
replace isco08=7317 if iscoco==7331
replace isco08=7318 if iscoco==7332
replace isco08=7319 if iscoco==7330
replace isco08=7320 if iscoco==7340
replace isco08=7321 if iscoco==7340
replace isco08=7322 if iscoco==7340
replace isco08=7323 if iscoco==7345
replace isco08=7400 if iscoco==7200
replace isco08=7410 if iscoco==7240
replace isco08=7411 if iscoco==7137
replace isco08=7412 if iscoco==7241
replace isco08=7413 if iscoco==7245
replace isco08=7420 if iscoco==7240
replace isco08=7421 if iscoco==7242
replace isco08=7421 if iscoco==7243
replace isco08=7422 if iscoco==7243
replace isco08=7500 if iscoco==7400
replace isco08=7510 if iscoco==7410
replace isco08=7511 if iscoco==7411
replace isco08=7512 if iscoco==7412
replace isco08=7513 if iscoco==7413
replace isco08=7514 if iscoco==7414
replace isco08=7515 if iscoco==7415
replace isco08=7516 if iscoco==7416
replace isco08=7520 if iscoco==7420
replace isco08=7521 if iscoco==7421
replace isco08=7522 if iscoco==7422
replace isco08=7523 if iscoco==7423
replace isco08=7530 if iscoco==7430
replace isco08=7531 if iscoco==7434
replace isco08=7532 if iscoco==7435
replace isco08=7533 if iscoco==7436
replace isco08=7534 if iscoco==7437
replace isco08=7535 if iscoco==7441
replace isco08=7536 if iscoco==7442
replace isco08=7540 if iscoco==7200
replace isco08=7541 if iscoco==7216
replace isco08=7542 if iscoco==7112
replace isco08=7543 if iscoco==3152
replace isco08=7544 if iscoco==7143
replace isco08=7549 if iscoco==7000
replace isco08=8000 if iscoco==8000
replace isco08=8100 if iscoco==8100
replace isco08=8110 if iscoco==8110
replace isco08=7111 if iscoco==8111
replace isco08=8112 if iscoco==8112
replace isco08=8113 if iscoco==8113
replace isco08=8114 if iscoco==8212
replace isco08=8120 if iscoco==8120
replace isco08=8121 if iscoco==8120
replace isco08=8122 if iscoco==8223
replace isco08=8130 if iscoco==8220
replace isco08=8131 if iscoco==8220
replace isco08=8232 if iscoco==8224
replace isco08=8140 if iscoco==8230
replace isco08=8141 if iscoco==8231
replace isco08=8142 if iscoco==8232
replace isco08=8143 if iscoco==8253
replace isco08=8150 if iscoco==8260
replace isco08=8151 if iscoco==8261
replace isco08=8152 if iscoco==8262
replace isco08=8153 if iscoco==8263
replace isco08=8154 if iscoco==8264
replace isco08=8155 if iscoco==8265
replace isco08=8156 if iscoco==8266
replace isco08=8157 if iscoco==8264
replace isco08=8159 if iscoco==8269
replace isco08=8160 if iscoco==8270
replace isco08=8170 if iscoco==8140
replace isco08=8171 if iscoco==8140
replace isco08=8172 if iscoco==8141
replace isco08=8180 if iscoco==8290
replace isco08=8181 if iscoco==8131
replace isco08=8182 if iscoco==8162
replace isco08=8183 if iscoco==8290
replace isco08=8189 if iscoco==8290
replace isco08=8200 if iscoco==8200
replace isco08=8210 if iscoco==8280
replace isco08=8211 if iscoco==8281
replace isco08=8212 if iscoco==8283
replace isco08=8219 if iscoco==8290
replace isco08=8300 if iscoco==8300
replace isco08=8310 if iscoco==8310
replace isco08=8311 if iscoco==8311
replace isco08=8312 if iscoco==8312
replace isco08=8320 if iscoco==8320
replace isco08=8321 if iscoco==8321
replace isco08=8322 if iscoco==8322
replace isco08=8320 if iscoco==8330
replace isco08=8331 if iscoco==8323
replace isco08=8332 if iscoco==8324
replace isco08=8340 if iscoco==8330
replace isco08=8341 if iscoco==8331
replace isco08=8342 if iscoco==8332
replace isco08=8343 if iscoco==8333
replace isco08=8344 if iscoco==8334
replace isco08=8350 if iscoco==8340
replace isco08=9000 if iscoco==9000
replace isco08=9100 if iscoco==9100
replace isco08=9110 if iscoco==9130
replace isco08=9111 if iscoco==9131
replace isco08=9112 if iscoco==9132
replace isco08=9130 if iscoco==9140
replace isco08=9121 if iscoco==9133
replace isco08=9122 if iscoco==9142
replace isco08=9123 if iscoco==9141
replace isco08=9129 if iscoco==9140
replace isco08=9200 if iscoco==9200
replace isco08=9210 if iscoco==9210
replace isco08=9211 if iscoco==9211
replace isco08=9212 if iscoco==9211
replace isco08=9213 if iscoco==9211
replace isco08=9214 if iscoco==9211
replace isco08=9215 if iscoco==9213
replace isco08=9216 if iscoco==9213
replace isco08=9300 if iscoco==9300
replace isco08=9310 if iscoco==9310
replace isco08=9311 if iscoco==9311
replace isco08=9312 if iscoco==9312
replace isco08=9313 if iscoco==9313
replace isco08=9320 if iscoco==9320
replace isco08=9321 if iscoco==9322
replace isco08=9329 if iscoco==9320
replace isco08=9330 if iscoco==9330
replace isco08=9331 if iscoco==9331
replace isco08=9332 if iscoco==9332
replace isco08=9333 if iscoco==9333
replace isco08=9334 if iscoco==9333
replace isco08=9400 if iscoco==9100
replace isco08=9410 if iscoco==9130
replace isco08=9411 if iscoco==5122
replace isco08=9412 if iscoco==9132
replace isco08=9500 if iscoco==9100
replace isco08=9510 if iscoco==9120
replace isco08=9520 if iscoco==9112
replace isco08=9600 if iscoco==9100
replace isco08=9610 if iscoco==9160
replace isco08=9611 if iscoco==9161
replace isco08=9612 if iscoco==9161
replace isco08=9613 if iscoco==9162
replace isco08=9620 if iscoco==9140
replace isco08=9621 if iscoco==9151
replace isco08=9622 if iscoco==9160
replace isco08=9624 if iscoco==9153
replace isco08=9624 if isco08==9160
replace isco08=9629 if iscoco==9100
}

  
{
gen computerisation =.

replace computerisation = 0.004 if (isco08==2351) | (isco08==1411) | (isco08==2265)
replace computerisation = 0.005 if (isco08==2266)
replace computerisation = 0.007 if (isco08==1345) | (isco08==1342) | (isco08==2634) ///
| (isco08==1344)
replace computerisation = 0.008 if (isco08==2330)
replace computerisation = 0.009 if (isco08==2221) | (isco08==2359)
replace computerisation = 0.011 if (isco08==2511)
replace computerisation = 0.012 if (isco08==2269) | (isco08==2262) | (isco08==2352) ///
| (isco08==2132)
replace computerisation = 0.014 if (isco08==1221) | (isco08==3341) | (isco08==2424) ///
| (isco08==2356)
replace computerisation = 0.015 if (isco08==1341)
replace computerisation = 0.016 if (isco08==3122)
replace computerisation = 0.017 if (isco08==2636) | (isco08==2145)
replace computerisation = 0.018 if (isco08==2161) | (isco08==1223) | (isco08==2143)
replace computerisation = 0.019 if (isco08==2142)
replace computerisation = 0.021 if (isco08==2264) | (isco08==2261) | (isco08==3431)
replace computerisation = 0.025 if (isco08==2133)
replace computerisation = 0.027 if (isco08==1222)
replace computerisation = 0.029 if (isco08==2163) | (isco08==2141)
replace computerisation = 0.030 if (isco08==1321) | (isco08==2522) | (isco08==2521) ///
| (isco08==3514)
replace computerisation = 0.032 if (isco08==2310)
replace computerisation = 0.034 if (isco08==2149)
replace computerisation = 0.035 if (isco08==2611) | (isco08==1330) | (isco08==3151)
replace computerisation = 0.037 if (isco08==3332)
replace computerisation = 0.038 if (isco08==2250) | (isco08==2651)
replace computerisation = 0.043 if (isco08==2653)
replace computerisation = 0.045 if (isco08==2652) | (isco08==2162)
replace computerisation = 0.046 if (isco08==3311)
replace computerisation = 0.047 if (isco08==1311) | (isco08==1312)
replace computerisation = 0.049 if (isco08==3258) | (isco08==2166)
replace computerisation = 0.050 if (isco08==7413)
replace computerisation = 0.055 if (isco08==3230)
replace computerisation = 0.059 if (isco08==1112)
replace computerisation = 0.060 if (isco08==2619)
replace computerisation = 0.061 if (isco08==3351) | (isco08==2113)
replace computerisation = 0.067 if (isco08==2653)
replace computerisation = 0.069 if (isco08==1211) | (isco08==3154)
replace computerisation = 0.070 if (isco08==2355)
replace computerisation = 0.071 if (isco08==1323) | (isco08==2421)
replace computerisation = 0.075 if (isco08==3423)
replace computerisation = 0.079 if (isco08==2342)
replace computerisation = 0.080 if (isco08==5311) | (isco08==2131)
replace computerisation = 0.082 if (isco08==2642)
replace computerisation = 0.083 if (isco08==1412)
replace computerisation = 0.084 if (isco08==1343)
replace computerisation = 0.085 if (isco08==2146)
replace computerisation = 0.086 if (isco08==2512)
replace computerisation = 0.087 if (isco08==2341) | (isco08==1120) | (isco08==5411)
replace computerisation = 0.100 if (isco08==2151)
replace computerisation = 0.106 if (isco08==2632)
replace computerisation = 0.110 if (isco08==2434)
replace computerisation = 0.114 if (isco08==1346)
replace computerisation = 0.118 if (isco08==2654)
replace computerisation = 0.122 if (isco08==2152)
replace computerisation = 0.130 if (isco08==3412) | (isco08==2354) | (isco08==5165) ///
| (isco08==2164)
replace computerisation = 0.132 if (isco08==2144)
replace computerisation = 0.134 if (isco08==2320)
replace computerisation = 0.140 if (isco08==2267)
replace computerisation = 0.142 if (isco08==1114)
replace computerisation = 0.148 if (isco08==2120)
replace computerisation = 0.150 if (isco08==7411) | (isco08==3152)
replace computerisation = 0.160 if (isco08==1420) | (isco08==5221)
replace computerisation = 0.163 if (isco08==2433)
replace computerisation = 0.169 if (isco08==3432)
replace computerisation = 0.170 if (isco08==3123) | (isco08==1431) | (isco08==3121)
replace computerisation = 0.172 if (isco08==3355)
replace computerisation = 0.173 if (isco08==2633)
replace computerisation = 0.180 if (isco08==2432) | (isco08==7541)
replace computerisation = 0.187 if (isco08==3259)
replace computerisation = 0.190 if (isco08==2111)
replace computerisation = 0.210 if (isco08==2643) | (isco08==2523)
replace computerisation = 0.220 if (isco08==2519) | (isco08==2529)
replace computerisation = 0.230 if (isco08==2422)
replace computerisation = 0.240 if (isco08==3116)
replace computerisation = 0.250 if (isco08==1322) | (isco08==1349) | (isco08==1439) ///
| (isco08==1213)
replace computerisation = 0.253 if (isco08==3153)
replace computerisation = 0.261 if (isco08==4221)
replace computerisation = 0.262 if (isco08==3211)
replace computerisation = 0.263 if (isco08==2423)
replace computerisation = 0.279 if (isco08==5169)
replace computerisation = 0.280 if (isco08==5222) | (isco08==3421)
replace computerisation = 0.296 if (isco08==2656)
replace computerisation = 0.298 if (isco08==3339)
replace computerisation = 0.300 if (isco08==3256)
replace computerisation = 0.313 if (isco08==5413)
replace computerisation = 0.322 if (isco08==2114)
replace computerisation = 0.324 if (isco08==2431) | (isco08==1212)
replace computerisation = 0.326 if (isco08==7127)
replace computerisation = 0.328 if (isco08==2641)
replace computerisation = 0.329 if (isco08==5141)
replace computerisation = 0.342 if (isco08==3119)
replace computerisation = 0.348 if (isco08==5113)
replace computerisation = 0.355 if (isco08==1219)
replace computerisation = 0.356 if (isco08==7232)
replace computerisation = 0.360 if (isco08==3324)
replace computerisation = 0.365 if (isco08==3434)
replace computerisation = 0.370 if (isco08==9122) | (isco08==2655) | (isco08==5163) ///
| (isco08==9311)
replace computerisation = 0.371 if (isco08==5142)
replace computerisation = 0.374 if (isco08==3422)
replace computerisation = 0.376 if (isco08==5111)
replace computerisation = 0.380 if (isco08==9321)
replace computerisation = 0.383 if (isco08==2621)
replace computerisation = 0.389 if (isco08==5112)
replace computerisation = 0.390 if (isco08==3353) | (isco08==7534)
replace computerisation = 0.392 if (isco08==3322)
replace computerisation = 0.402 if (isco08==5322)
replace computerisation = 0.405 if (isco08==2412)
replace computerisation = 0.410 if (isco08==8332) | (isco08==7535)
replace computerisation = 0.420 if (isco08==3143)
replace computerisation = 0.429 if (isco08==5245)
replace computerisation = 0.430 if (isco08==2631)
replace computerisation = 0.445 if (isco08==3240)
replace computerisation = 0.457 if (isco08==7312)
replace computerisation = 0.460 if (isco08==2413)
replace computerisation = 0.463 if (isco08==5419)
replace computerisation = 0.464 if (isco08==5164)
replace computerisation = 0.467 if (isco08==7314)
replace computerisation = 0.470 if (isco08==5321)
replace computerisation = 0.471 if (isco08==7234)
replace computerisation = 0.475 if (isco08==3214)
replace computerisation = 0.477 if (isco08==3115)
replace computerisation = 0.480 if (isco08==9611) | (isco08==7542) | (isco08==8344)
replace computerisation = 0.485 if (isco08==7126)
replace computerisation = 0.509 if (isco08==7549)
replace computerisation = 0.510 if (isco08==3312) | (isco08==5242)
replace computerisation = 0.513 if (isco08==3118)
replace computerisation = 0.514 if (isco08==9333)
replace computerisation = 0.520 if (isco08==2622) | (isco08==2612) | (isco08==7318) ///
| (isco08==7536)
replace computerisation = 0.530 if (isco08==3257)
replace computerisation = 0.532 if (isco08==7532)
replace computerisation = 0.535 if (isco08==3141)
replace computerisation = 0.536 if (isco08==7421)
replace computerisation = 0.538 if (isco08==3433) | (isco08==7311)
replace computerisation = 0.560 if (isco08==5312)
replace computerisation = 0.563 if (isco08==8312)
replace computerisation = 0.565 if (isco08==3112) | (isco08==7321)
replace computerisation = 0.568 if (isco08==8322)
replace computerisation = 0.570 if (isco08==6111)
replace computerisation = 0.573 if (isco08==9112)
replace computerisation = 0.575 if (isco08==3117) | (isco08==4224)
replace computerisation = 0.583 if (isco08==7422)
replace computerisation = 0.585 if (isco08==7119)
replace computerisation = 0.587 if (isco08==5329)
replace computerisation = 0.590 if (isco08==1324)
replace computerisation = 0.595 if (isco08==3251)
replace computerisation = 0.597 if (isco08==3132)
replace computerisation = 0.600 if (isco08==3521)
replace computerisation = 0.610 if (isco08==3435)
replace computerisation = 0.612 if (isco08==8331)
replace computerisation = 0.614 if (isco08==3131)
replace computerisation = 0.616 if (isco08==4212)
replace computerisation = 0.622 if (isco08==7233)
replace computerisation = 0.630 if (isco08==2165)
replace computerisation = 0.640 if (isco08==3333) | (isco08==9334)
replace computerisation = 0.643 if (isco08==3323) | (isco08==9622)
replace computerisation = 0.644 if (isco08==7412)
replace computerisation = 0.645 if (isco08==7231)
replace computerisation = 0.654 if (isco08==8343)
replace computerisation = 0.660 if (isco08==5153) | (isco08==9123)
replace computerisation = 0.662 if (isco08==3321)
replace computerisation = 0.670 if (isco08==6113) | (isco08==2112)
replace computerisation = 0.675 if (isco08==7515)
replace computerisation = 0.677 if (isco08==8311)
replace computerisation = 0.679 if (isco08==3334)
replace computerisation = 0.680 if (isco08==3343)
replace computerisation = 0.685 if (isco08==3212)
replace computerisation = 0.690 if (isco08==9111)
replace computerisation = 0.696 if (isco08==8111)
replace computerisation = 0.700 if (isco08==6222)
replace computerisation = 0.710 if (isco08==8157) | (isco08==3254)
replace computerisation = 0.713 if (isco08==7214)
replace computerisation = 0.720 if (isco08==7115)
replace computerisation = 0.725 if (isco08==8350)
replace computerisation = 0.730 if (isco08==7125) | (isco08==8152)
replace computerisation = 0.732 if (isco08==5120)
replace computerisation = 0.733 if (isco08==7544)
replace computerisation = 0.735 if (isco08==7124)
replace computerisation = 0.740 if (isco08==8171)
replace computerisation = 0.755 if (isco08==4222)
replace computerisation = 0.760 if (isco08==6130) | (isco08==6221) | (isco08==6121) ///
| (isco08==6122)
replace computerisation = 0.770 if (isco08==5132)
replace computerisation = 0.772 if (isco08==8113)
replace computerisation = 0.773 if (isco08==7222)
replace computerisation = 0.775 if (isco08==7212) | (isco08==3155)
replace computerisation = 0.780 if (isco08==3511) | (isco08==7213)
replace computerisation = 0.790 if (isco08==9629) | (isco08==8341)
replace computerisation = 0.792 if (isco08==6210)
replace computerisation = 0.800 if (isco08==9313) | (isco08==7132)
replace computerisation = 0.805 if (isco08==8211)
replace computerisation = 0.810 if (isco08==7131) | (isco08==7211) | (isco08==8143) ///
| (isco08==4131)
replace computerisation = 0.813 if (isco08==8181)
replace computerisation = 0.816 if (isco08==8160)
replace computerisation = 0.820 if (isco08==7112) | (isco08==7122)
replace computerisation = 0.822 if (isco08==8141)
replace computerisation = 0.825 if (isco08==3113) | (isco08==3134)
replace computerisation = 0.830 if (isco08==7322) | (isco08==9216) | (isco08==9129)
replace computerisation = 0.837 if (isco08==7315)
replace computerisation = 0.840 if (isco08==3114) | (isco08==9329) | (isco08==3522) ///
| (isco08==7531)
replace computerisation = 0.845 if (isco08==7511)
replace computerisation = 0.847 if (isco08==8131)
replace computerisation = 0.850 if (isco08==9412) | (isco08==3113)
replace computerisation = 0.857 if (isco08==4321)
replace computerisation = 0.860 if (isco08==4412) | (isco08==8172) | (isco08==7113)
replace computerisation = 0.870 if (isco08==9215)
replace computerisation = 0.871 if (isco08==7223)
replace computerisation = 0.880 if (isco08==9312) | (isco08==8121) | (isco08==4322) ///
| (isco08==8114) | (isco08==3135)
replace computerisation = 0.883 if (isco08==7114)
replace computerisation = 0.885 if (isco08==9621)
replace computerisation = 0.890 if (isco08==7512) | (isco08==7215) | (isco08==8153) ///
| (isco08==8112) | (isco08==8182)
replace computerisation = 0.892 if (isco08==8342)
replace computerisation = 0.895 if (isco08==5414) | (isco08==9623)
replace computerisation = 0.900 if (isco08==5131) | (isco08==7121) | (isco08==5230) ///
| (isco08==4416)
replace computerisation = 0.906 if (isco08==8142)
replace computerisation = 0.910 if (isco08==4225)
replace computerisation = 0.915 if (isco08==7522)
replace computerisation = 0.920 if (isco08==3213)
replace computerisation = 0.922 if (isco08==8212) | (isco08==8189)
replace computerisation = 0.925 if (isco08==7224)
replace computerisation = 0.930 if (isco08==5246) | (isco08==9612) | (isco08==7221) ///
| (isco08==3352)
replace computerisation = 0.940 if (isco08==3359) | (isco08==5151) | (isco08==4227) ///
| (isco08==5211) | (isco08==5243) | (isco08==9520) | (isco08==5152)
replace computerisation = 0.945 if (isco08==4415)
replace computerisation = 0.950 if (isco08==5223) | (isco08==9214) | (isco08==4214) ///
| (isco08==7313) | (isco08==7323)
replace computerisation = 0.953 if (isco08==3315)
replace computerisation = 0.957 if (isco08==2411)
replace computerisation = 0.960 if (isco08==4226) | (isco08==4323) | (isco08==8151)
replace computerisation = 0.965 if (isco08==4223) | (isco08==4211)
replace computerisation = 0.970 if (isco08==4110) | (isco08==4311) | (isco08==4313) ///
| (isco08==5249) | (isco08==3142) | (isco08==4411) | (isco08==8154) | (isco08==8219) ///
| (isco08==8156)
replace computerisation = 0.980 if (isco08==3313) | (isco08==8183) | (isco08==3342)
replace computerisation = 0.985 if (isco08==3331)
replace computerisation = 0.990 if (isco08==5244) | (isco08==4132) | (isco08==8132)

label variable computerisation "Probability of Computerisation"
gen comp_groups=.
replace comp_groups = 5 if computerisation <=.100
replace comp_groups = 4 if computerisation <=.80
replace comp_groups = 3 if computerisation <=.60
replace comp_groups = 2 if computerisation <=.40
replace comp_groups = 1 if computerisation <=.20



}

{
gen computerisationpart =.

replace computerisationpart = 0.004 if (isco08p==2351) | (isco08p==1411) | (isco08p==2265)
replace computerisationpart = 0.005 if (isco08p==2266)
replace computerisationpart = 0.007 if (isco08p==1345) | (isco08p==1342) | (isco08p==2634) ///
| (isco08p==1344)
replace computerisationpart = 0.008 if (isco08p==2330)
replace computerisationpart = 0.009 if (isco08p==2221) | (isco08p==2359)
replace computerisationpart = 0.011 if (isco08p==2511)
replace computerisationpart = 0.012 if (isco08p==2269) | (isco08p==2262) | (isco08p==2352) ///
| (isco08==2132)
replace computerisationpart = 0.014 if (isco08p==1221) | (isco08p==3341) | (isco08p==2424) ///
| (isco08p==2356)
replace computerisationpart = 0.015 if (isco08p==1341)
replace computerisationpart = 0.016 if (isco08p==3122)
replace computerisationpart = 0.017 if (isco08p==2636) | (isco08p==2145)
replace computerisationpart = 0.018 if (isco08p==2161) | (isco08p==1223) | (isco08p==2143)
replace computerisationpart = 0.019 if (isco08p==2142)
replace computerisationpart = 0.021 if (isco08p==2264) | (isco08==2261) | (isco08p==3431)
replace computerisationpart = 0.025 if (isco08p==2133)
replace computerisationpart = 0.027 if (isco08p==1222)
replace computerisationpart = 0.029 if (isco08p==2163) | (isco08p==2141)
replace computerisationpart = 0.030 if (isco08p==1321) | (isco08p==2522) | (isco08p==2521) ///
| (isco08==3514)
replace computerisationpart = 0.032 if (isco08p==2310)
replace computerisationpart = 0.034 if (isco08p==2149)
replace computerisationpart = 0.035 if (isco08p==2611) | (isco08p==1330) | (isco08p==3151)
replace computerisationpart = 0.037 if (isco08p==3332)
replace computerisationpart = 0.038 if (isco08p==2250) | (isco08p==2651)
replace computerisationpart = 0.043 if (isco08p==2653)
replace computerisationpart = 0.045 if (isco08p==2652) | (isco08p==2162)
replace computerisationpart = 0.046 if (isco08p==3311)
replace computerisationpart = 0.047 if (isco08p==1311) | (isco08p==1312)
replace computerisationpart = 0.049 if (isco08p==3258) | (isco08p==2166)
replace computerisationpart = 0.050 if (isco08p==7413)
replace computerisationpart = 0.055 if (isco08p==3230)
replace computerisationpart = 0.059 if (isco08p==1112)
replace computerisationpart = 0.060 if (isco08p==2619)
replace computerisationpart = 0.061 if (isco08p==3351) | (isco08p==2113)
replace computerisationpart = 0.067 if (isco08p==2653)
replace computerisationpart = 0.069 if (isco08p==1211) | (isco08p==3154)
replace computerisationpart = 0.070 if (isco08p==2355)
replace computerisationpart = 0.071 if (isco08p==1323) | (isco08p==2421)
replace computerisationpart = 0.075 if (isco08p==3423)
replace computerisationpart = 0.079 if (isco08p==2342)
replace computerisationpart = 0.080 if (isco08p==5311) | (isco08p==2131)
replace computerisationpart = 0.082 if (isco08p==2642)
replace computerisationpart = 0.083 if (isco08p==1412)
replace computerisationpart = 0.084 if (isco08p==1343)
replace computerisationpart = 0.085 if (isco08p==2146)
replace computerisationpart = 0.086 if (isco08p==2512)
replace computerisationpart = 0.087 if (isco08p==2341) | (isco08p==1120) | (isco08p==5411)
replace computerisationpart = 0.100 if (isco08p==2151)
replace computerisationpart = 0.106 if (isco08p==2632)
replace computerisationpart = 0.110 if (isco08p==2434)
replace computerisationpart = 0.114 if (isco08p==1346)
replace computerisationpart = 0.118 if (isco08p==2654)
replace computerisationpart = 0.122 if (isco08p==2152)
replace computerisationpart = 0.130 if (isco08p==3412) | (isco08p==2354) | (isco08p==5165) ///
| (isco08p==2164)
replace computerisationpart = 0.132 if (isco08p==2144)
replace computerisationpart = 0.134 if (isco08p==2320)
replace computerisationpart = 0.140 if (isco08p==2267)
replace computerisationpart = 0.142 if (isco08p==1114)
replace computerisationpart = 0.148 if (isco08p==2120)
replace computerisationpart = 0.150 if (isco08p==7411) | (isco08p==3152)
replace computerisationpart = 0.160 if (isco08p==1420) | (isco08p==5221)
replace computerisationpart = 0.163 if (isco08p==2433)
replace computerisationpart = 0.169 if (isco08p==3432)
replace computerisationpart = 0.170 if (isco08p==3123) | (isco08p==1431) | (isco08p==3121)
replace computerisationpart = 0.172 if (isco08p==3355)
replace computerisationpart = 0.173 if (isco08p==2633)
replace computerisationpart = 0.180 if (isco08p==2432) | (isco08p==7541)
replace computerisationpart = 0.187 if (isco08p==3259)
replace computerisationpart = 0.190 if (isco08p==2111)
replace computerisationpart = 0.210 if (isco08p==2643) | (isco08p==2523)
replace computerisationpart = 0.220 if (isco08p==2519) | (isco08p==2529)
replace computerisationpart = 0.230 if (isco08p==2422)
replace computerisationpart = 0.240 if (isco08p==3116)
replace computerisationpart = 0.250 if (isco08p==1322) | (isco08p==1349) | (isco08p==1439) ///
| (isco08p==1213)
replace computerisationpart = 0.253 if (isco08p==3153)
replace computerisationpart = 0.261 if (isco08p==4221)
replace computerisationpart = 0.262 if (isco08p==3211)
replace computerisationpart = 0.263 if (isco08p==2423)
replace computerisationpart = 0.279 if (isco08p==5169)
replace computerisationpart = 0.280 if (isco08p==5222) | (isco08p==3421)
replace computerisationpart = 0.296 if (isco08p==2656)
replace computerisationpart = 0.298 if (isco08p==3339)
replace computerisationpart = 0.300 if (isco08p==3256)
replace computerisationpart = 0.313 if (isco08p==5413)
replace computerisationpart = 0.322 if (isco08p==2114)
replace computerisationpart = 0.324 if (isco08p==2431) | (isco08p==1212)
replace computerisationpart = 0.326 if (isco08p==7127)
replace computerisationpart = 0.328 if (isco08p==2641)
replace computerisationpart = 0.329 if (isco08p==5141)
replace computerisationpart = 0.342 if (isco08p==3119)
replace computerisationpart = 0.348 if (isco08p==5113)
replace computerisationpart = 0.355 if (isco08p==1219)
replace computerisationpart = 0.356 if (isco08p==7232)
replace computerisationpart = 0.360 if (isco08p==3324)
replace computerisationpart = 0.365 if (isco08p==3434)
replace computerisationpart = 0.370 if (isco08p==9122) | (isco08p==2655) | (isco08p==5163) ///
| (isco08p==9311)
replace computerisationpart = 0.371 if (isco08p==5142)
replace computerisationpart = 0.374 if (isco08p==3422)
replace computerisationpart = 0.376 if (isco08p==5111)
replace computerisationpart = 0.380 if (isco08p==9321)
replace computerisationpart = 0.383 if (isco08p==2621)
replace computerisationpart = 0.389 if (isco08p==5112)
replace computerisationpart = 0.390 if (isco08p==3353) | (isco08p==7534)
replace computerisationpart = 0.392 if (isco08p==3322)
replace computerisationpart = 0.402 if (isco08p==5322)
replace computerisationpart = 0.405 if (isco08p==2412)
replace computerisationpart = 0.410 if (isco08p==8332) | (isco08p==7535)
replace computerisationpart = 0.420 if (isco08p==3143)
replace computerisationpart = 0.429 if (isco08p==5245)
replace computerisationpart = 0.430 if (isco08p==2631)
replace computerisationpart = 0.445 if (isco08p==3240)
replace computerisationpart = 0.457 if (isco08p==7312)
replace computerisationpart = 0.460 if (isco08p==2413)
replace computerisationpart = 0.463 if (isco08p==5419)
replace computerisationpart = 0.464 if (isco08p==5164)
replace computerisationpart = 0.467 if (isco08p==7314)
replace computerisationpart = 0.470 if (isco08p==5321)
replace computerisationpart = 0.471 if (isco08p==7234)
replace computerisationpart = 0.475 if (isco08p==3214)
replace computerisationpart = 0.477 if (isco08p==3115)
replace computerisationpart = 0.480 if (isco08p==9611) | (isco08p==7542) | (isco08p==8344)
replace computerisationpart = 0.485 if (isco08p==7126)
replace computerisationpart = 0.509 if (isco08p==7549)
replace computerisationpart = 0.510 if (isco08p==3312) | (isco08p==5242)
replace computerisationpart = 0.513 if (isco08p==3118)
replace computerisationpart = 0.514 if (isco08p==9333)
replace computerisationpart = 0.520 if (isco08p==2622) | (isco08p==2612) | (isco08p==7318) ///
| (isco08p==7536)
replace computerisationpart = 0.530 if (isco08p==3257)
replace computerisationpart = 0.532 if (isco08p==7532)
replace computerisationpart = 0.535 if (isco08p==3141)
replace computerisationpart = 0.536 if (isco08p==7421)
replace computerisationpart = 0.538 if (isco08p==3433) | (isco08p==7311)
replace computerisationpart = 0.560 if (isco08p==5312)
replace computerisationpart = 0.563 if (isco08p==8312)
replace computerisationpart = 0.565 if (isco08p==3112) | (isco08p==7321)
replace computerisationpart = 0.568 if (isco08p==8322)
replace computerisationpart = 0.570 if (isco08p==6111)
replace computerisationpart = 0.573 if (isco08p==9112)
replace computerisationpart = 0.575 if (isco08p==3117) | (isco08p==4224)
replace computerisationpart = 0.583 if (isco08p==7422)
replace computerisationpart = 0.585 if (isco08p==7119)
replace computerisationpart = 0.587 if (isco08p==5329)
replace computerisationpart = 0.590 if (isco08p==1324)
replace computerisationpart = 0.595 if (isco08p==3251)
replace computerisationpart = 0.597 if (isco08p==3132)
replace computerisationpart = 0.600 if (isco08p==3521)
replace computerisationpart = 0.610 if (isco08p==3435)
replace computerisationpart = 0.612 if (isco08p==8331)
replace computerisationpart = 0.614 if (isco08p==3131)
replace computerisationpart = 0.616 if (isco08p==4212)
replace computerisationpart = 0.622 if (isco08p==7233)
replace computerisationpart = 0.630 if (isco08p==2165)
replace computerisationpart = 0.640 if (isco08p==3333) | (isco08p==9334)
replace computerisationpart = 0.643 if (isco08p==3323) | (isco08p==9622)
replace computerisationpart = 0.644 if (isco08p==7412)
replace computerisationpart = 0.645 if (isco08p==7231)
replace computerisationpart = 0.654 if (isco08p==8343)
replace computerisationpart = 0.660 if (isco08p==5153) | (isco08p==9123)
replace computerisationpart = 0.662 if (isco08p==3321)
replace computerisationpart = 0.670 if (isco08p==6113) | (isco08p==2112)
replace computerisationpart = 0.675 if (isco08p==7515)
replace computerisationpart = 0.677 if (isco08p==8311)
replace computerisationpart = 0.679 if (isco08p==3334)
replace computerisationpart = 0.680 if (isco08p==3343)
replace computerisationpart = 0.685 if (isco08p==3212)
replace computerisationpart = 0.690 if (isco08p==9111)
replace computerisationpart = 0.696 if (isco08p==8111)
replace computerisationpart = 0.700 if (isco08p==6222)
replace computerisationpart = 0.710 if (isco08p==8157) | (isco08p==3254)
replace computerisationpart = 0.713 if (isco08p==7214)
replace computerisationpart = 0.720 if (isco08p==7115)
replace computerisationpart = 0.725 if (isco08p==8350)
replace computerisationpart = 0.730 if (isco08p==7125) | (isco08p==8152)
replace computerisationpart = 0.732 if (isco08p==5120)
replace computerisationpart = 0.733 if (isco08p==7544)
replace computerisationpart = 0.735 if (isco08p==7124)
replace computerisationpart = 0.740 if (isco08p==8171)
replace computerisationpart = 0.755 if (isco08p==4222)
replace computerisationpart = 0.760 if (isco08p==6130) | (isco08p==6221) | (isco08p==6121) ///
| (isco08p==6122)
replace computerisationpart = 0.770 if (isco08p==5132)
replace computerisationpart = 0.772 if (isco08p==8113)
replace computerisationpart = 0.773 if (isco08p==7222)
replace computerisationpart = 0.775 if (isco08p==7212) | (isco08p==3155)
replace computerisationpart = 0.780 if (isco08p==3511) | (isco08p==7213)
replace computerisationpart = 0.790 if (isco08p==9629) | (isco08p==8341)
replace computerisationpart = 0.792 if (isco08p==6210)
replace computerisationpart = 0.800 if (isco08p==9313) | (isco08p==7132)
replace computerisationpart = 0.805 if (isco08p==8211)
replace computerisationpart = 0.810 if (isco08p==7131) | (isco08p==7211) | (isco08p==8143) ///
| (isco08p==4131)
replace computerisationpart = 0.813 if (isco08p==8181)
replace computerisationpart = 0.816 if (isco08p==8160)
replace computerisationpart = 0.820 if (isco08p==7112) | (isco08p==7122)
replace computerisationpart = 0.822 if (isco08p==8141)
replace computerisationpart = 0.825 if (isco08p==3113) | (isco08p==3134)
replace computerisationpart = 0.830 if (isco08p==7322) | (isco08p==9216) | (isco08p==9129)
replace computerisationpart = 0.837 if (isco08p==7315)
replace computerisationpart = 0.840 if (isco08p==3114) | (isco08p==9329) | (isco08p==3522) ///
| (isco08p==7531)
replace computerisationpart = 0.845 if (isco08p==7511)
replace computerisationpart = 0.847 if (isco08p==8131)
replace computerisationpart = 0.850 if (isco08p==9412) | (isco08p==3113)
replace computerisationpart = 0.857 if (isco08p==4321)
replace computerisationpart = 0.860 if (isco08p==4412) | (isco08p==8172) | (isco08p==7113)
replace computerisationpart = 0.870 if (isco08p==9215)
replace computerisationpart = 0.871 if (isco08p==7223)
replace computerisationpart = 0.880 if (isco08p==9312) | (isco08p==8121) | (isco08p==4322) ///
| (isco08p==8114) | (isco08p==3135)
replace computerisationpart = 0.883 if (isco08p==7114)
replace computerisationpart = 0.885 if (isco08p==9621)
replace computerisationpart = 0.890 if (isco08p==7512) | (isco08p==7215) | (isco08p==8153) ///
| (isco08p==8112) | (isco08p==8182)
replace computerisationpart = 0.892 if (isco08p==8342)
replace computerisationpart = 0.895 if (isco08p==5414) | (isco08p==9623)
replace computerisationpart = 0.900 if (isco08p==5131) | (isco08p==7121) | (isco08p==5230) ///
| (isco08p==4416)
replace computerisationpart = 0.906 if (isco08p==8142)
replace computerisationpart = 0.910 if (isco08p==4225)
replace computerisationpart = 0.915 if (isco08p==7522)
replace computerisationpart = 0.920 if (isco08p==3213)
replace computerisationpart = 0.922 if (isco08p==8212) | (isco08p==8189)
replace computerisationpart = 0.925 if (isco08p==7224)
replace computerisationpart = 0.930 if (isco08p==5246) | (isco08p==9612) | (isco08p==7221) ///
| (isco08p==3352)
replace computerisationpart = 0.940 if (isco08p==3359) | (isco08p==5151) | (isco08p==4227) ///
| (isco08p==5211) | (isco08p==5243) | (isco08p==9520) | (isco08p==5152)
replace computerisationpart = 0.945 if (isco08p==4415)
replace computerisationpart = 0.950 if (isco08p==5223) | (isco08p==9214) | (isco08p==4214) ///
| (isco08p==7313) | (isco08p==7323)
replace computerisationpart = 0.953 if (isco08p==3315)
replace computerisationpart = 0.957 if (isco08p==2411)
replace computerisationpart = 0.960 if (isco08p==4226) | (isco08p==4323) | (isco08p==8151)
replace computerisationpart = 0.965 if (isco08p==4223) | (isco08p==4211)
replace computerisationpart = 0.970 if (isco08p==4110) | (isco08p==4311) | (isco08p==4313) ///
| (isco08p==5249) | (isco08p==3142) | (isco08p==4411) | (isco08p==8154) | (isco08p==8219) ///
| (isco08p==8156)
replace computerisationpart = 0.980 if (isco08p==3313) | (isco08p==8183) | (isco08p==3342)
replace computerisationpart = 0.985 if (isco08p==3331)
replace computerisationpart = 0.990 if (isco08p==5244) | (isco08p==4132) | (isco08p==8132)


}

gen routinefam =.
replace routinefam=1 if computerisation <0.5 & computerisationpart <0.5
replace routinefam=2 if computerisation >0.5 & computerisationpart <0.5
replace routinefam=2 if computerisation <0.5 & computerisationpart >0.5
replace routinefam=3 if computerisation >0.5 & computerisationpart >0.5



*/For below coding 1000: armed forces, should all be 100
replace iscoco=100 if inlist(isco08,0,100,110,200,210,300,310)

*/Missings etc.
replace iscoco = isco08 if iscoco==. & isco08>10000 & essround==6

*/Check: as we want, all observations are recoded
sum isco08 iscoco if isco08~=. & iscoco==. 

*/Step 2: We move from a 4-digit to a 2-digit occupational identifier

*list str_isco08 if isco08~=. & iscoco==., noo sep(0) clean
sum isco08 if isco08~=. & iscoco==.
local missing = r(N)
sum isco08 if isco08~=. & iscoco~=.
local all = r(N)
display `missing'/`all'*100

list iscoco if iscoco<1000 & iscoco~=100 & iscoco~=.
list iscoco if iscoco>9333 & iscoco<66666


foreach var of varlist iscoco isco08 {
gen str_`var'=string(`var')
replace str_`var'="0100" if str_`var'=="100"
}
sum iscoco if str_iscoco=="0100"


foreach x in iscoco {
gen `x'2 = substr(str_`x',1,2) if `x'<9334
replace `x'2 = "." if `x'2==""
}

drop str_*

destring iscoco2, replace

foreach var of varlist iscoco {
replace `var'=. if essround==6

}


label var iscoco2 "ISCO88 at the 2-digit"


** I generate occupation names
gen iscoco2n="."
replace iscoco2n="Legislators and senior officials" if iscoco2==11
	replace iscoco2n="Corporate managers" if iscoco2==12
	replace iscoco2n="General managers" if iscoco2==13
	replace iscoco2n="Physical, mathematical and engineering science professionals" if iscoco2==21
	replace iscoco2n="Life science and health professionals" if iscoco2==22
	replace iscoco2n="Teaching professionals" if iscoco2==23
	replace iscoco2n="Other professionals" if iscoco2==24
	replace iscoco2n="Physical and engineering science associate professionals" if iscoco2==31
	replace iscoco2n="Life science and health associate professionals" if iscoco2==32
	replace iscoco2n="Teaching associate professionals" if iscoco2==33
	replace iscoco2n="Other associate professionals" if iscoco2==34
	replace iscoco2n="Office clerks" if iscoco2==41
	replace iscoco2n="Customer services clerks" if iscoco2==42
	replace iscoco2n="Personal and protective services workers" if iscoco2==51
	replace iscoco2n="Models, salespersons and demonstrators" if iscoco2==52
	replace iscoco2n="Market-oriented skilled agricultural and fishery workers" if iscoco2==61
	replace iscoco2n="Subsistence agricultural and fishery workers" if iscoco2==62
	replace iscoco2n="Extraction and building trades workers" if iscoco2==71
	replace iscoco2n="Metal, machinery and related trades workers" if iscoco2==72
	replace iscoco2n="Precision, handicraft, printing and related trades workers" if iscoco2==73
	replace iscoco2n="Other craft and related trades workers" if iscoco2==74
	replace iscoco2n="Stationary-plant and related operators" if iscoco2==81
	replace iscoco2n="Machine operators and assemblers" if iscoco2==82
	replace iscoco2n="Drivers and mobile-plant operators" if iscoco2==83
	replace iscoco2n="Sales and services elementary occupations" if iscoco2==91
	replace iscoco2n="Agricultural, fishery and related labourers" if iscoco2==92
	replace iscoco2n="Labourers in mining, construction, manufacturing and transport" if iscoco2==93
	replace iscoco2n="Armed forces" if iscoco2==01
label var iscoco2n "Names of iscoco2 coding"


******************************************************************
*********************** 4. RTI and Offshoring ********************
******************************************************************
*/ here we code rti2 and offshoring indices 
*/ Include the routinisation and offshoring indices at the 2-digit level from Goos et al. (2014)
*/ used by Gingrich (2019) + Thewissen & Rueda (2017)

*/ Occupational dummies
 	gen iscocore=.
    replace iscocore=12 if substr(string(iscoco), 1, 2) == "12"
    replace iscocore=13 if substr(string(iscoco), 1, 3) == "13"
    replace iscocore=21 if substr(string(iscoco), 2, 1) == "21"
    replace iscocore=22 if substr(string(iscoco), 2, 2) == "22"
    replace iscocore=24 if substr(string(iscoco), 2, 4) == "24"
    replace iscocore=31 if substr(string(iscoco), 3, 1) == "31"
    replace iscocore=32 if substr(string(iscoco), 3, 2) == "32"
	replace iscocore=41 if substr(string(iscoco), 4, 1) == "41"
	replace iscocore=42 if substr(string(iscoco), 4, 2) == "42"
	replace iscocore=51 if substr(string(iscoco), 5, 1) == "51"
	replace iscocore=52 if substr(string(iscoco), 5, 2) == "52"
	replace iscocore=71 if substr(string(iscoco), 7, 1) == "71"
	replace iscocore=72 if substr(string(iscoco), 7, 2) == "72"
	replace iscocore=73 if substr(string(iscoco), 7, 3) == "73"
	replace iscocore=74 if substr(string(iscoco), 7, 4) == "74"
	replace iscocore=81 if substr(string(iscoco), 8, 1) == "81"
	replace iscocore=82 if substr(string(iscoco), 8, 2) == "82"
	replace iscocore=91 if substr(string(iscoco), 9, 1) == "91"
	replace iscocore=93 if substr(string(iscoco), 9, 3) == "93"
	 
	replace iscocore=12 if substr(string(isco08), 1, 2) == "12"
    replace iscocore=13 if substr(string(isco08),  1, 2) == "13"
    replace iscocore=21 if substr(string(isco08), 1, 2) == "21"
    replace iscocore=22 if substr(string(isco08), 1, 2) == "22"
    replace iscocore=24 if substr(string(isco08),  1, 2) == "24"
    replace iscocore=31 if substr(string(isco08),  1, 2) == "31"
    replace iscocore=32 if substr(string(isco08), 1, 2) == "32"
	replace iscocore=41 if substr(string(isco08),  1, 2) == "41"
	replace iscocore=42 if substr(string(isco08), 1, 2)  == "42"
	replace iscocore=51 if substr(string(isco08), 1, 2)  == "51"
	replace iscocore=52 if substr(string(isco08), 1, 2)  == "52"
	replace iscocore=71 if substr(string(isco08), 1, 2)  == "71"
	replace iscocore=72 if substr(string(isco08), 1, 2)  == "72"
	replace iscocore=73 if substr(string(isco08), 1, 2)  == "73"
	replace iscocore=74 if substr(string(isco08), 1, 2)  == "74"
	replace iscocore=81 if substr(string(isco08), 1, 2)  == "81"
	replace iscocore=82 if substr(string(isco08), 1, 2)  == "82"
	replace iscocore=91 if substr(string(isco08), 1, 2)  == "91"
	replace iscocore=93 if substr(string(isco08), 1, 2) == "93"
	
gen rti2=.
replace rti2 = -1.52 if iscocore  == 13

replace rti2 = -1.5 if iscocore  == 83

replace rti2 = -1 if iscocore  == 22

replace rti2 = -.82 if iscocore  == 21

replace rti2 = -.75 if iscocore  == 12

replace rti2 = -.73 if iscocore  == 24

replace rti2 = -.6 if iscocore  == 51

replace rti2 = -.44 if iscocore  == 34

replace rti2 = -.4 if iscocore  == 31

replace rti2 = -.33 if iscocore  == 32

replace rti2 = -.19 if iscocore  == 71

replace rti2 = .03 if iscocore  == 91

replace rti2 = .05 if iscocore  == 52

replace rti2 = .32 if iscocore  == 81

replace rti2 = .45 if iscocore  == 93

replace rti2 = .46 if iscocore  == 72

replace rti2 = .49 if iscocore  == 82

replace rti2 = 1.24 if iscocore  == 74

replace rti2 = 1.41 if iscocore  == 42

replace rti2 = 1.59 if iscocore  == 73

replace rti2 = 2.24 if iscocore  == 41

gen rti2=.
replace rti2 = -1.52 if  iscoco2  == 13

replace rti2 = -1.5 if  iscoco2  == 83

replace rti2 = -1 if  iscoco2  == 22

replace rti2 = -.82 if  iscoco2  == 21

replace rti2 = -.75 if  iscoco2  == 12

replace rti2 = -.73 if  iscoco2  == 24

replace rti2 = -.6 if  iscoco2  == 51

replace rti2 = -.44 if  iscoco2  == 34

replace rti2 = -.4 if  iscoco2  == 31

replace rti2 = -.33 if  iscoco2  == 32

replace rti2 = -.19 if  iscoco2  == 71

replace rti2 = .03 if  iscoco2  == 91

replace rti2 = .05 if  iscoco2  == 52

replace rti2 = .32 if  iscoco2  == 81

replace rti2 = .45 if  iscoco2  == 93

replace rti2 = .46 if  iscoco2  == 72

replace rti2 = .49 if  iscoco2  == 82

replace rti2 = 1.24 if  iscoco2  == 74

replace rti2 = 1.41 if  iscoco2  == 42

replace rti2 = 1.59 if  iscoco2  == 73

replace rti2 = 2.24 if  iscoco2  == 41

*/normalising it between 0-1 for simplicity

gen offsh=.
replace offsh=-0.32 if iscoco2==12
replace offsh=1.05 if iscoco2==21
replace offsh=-0.76 if iscoco2==22
replace offsh=0.21 if iscoco2==24
replace offsh=-0.63 if iscoco2==13
replace offsh=-0.12 if iscoco2==31
replace offsh=0.10 if iscoco2==34
replace offsh=-0.75 if iscoco2==32

replace offsh=1.59 if iscoco2==81
replace offsh=-0.45 if iscoco2==72
replace offsh=-1.00 if iscoco2==83
replace offsh=0.40 if iscoco2==41
replace offsh=1.66 if iscoco2==73
replace offsh=-0.93 if iscoco2==71
replace offsh=-0.25 if iscoco2==42
replace offsh=2.35 if iscoco2==82
replace offsh=1.15 if iscoco2==74

replace offsh=-0.66 if iscoco2==93
replace offsh=-0.94 if iscoco2==51
replace offsh=-0.89 if iscoco2==52
replace offsh=-0.81 if iscoco2==91


*/normalising it between 0-1 for simplicity

foreach v in rti2{ 
      gen `v'2 = (`v' + 2.24)/4.48
	  label var `v'2 "rti normalised 0-1" 
	  rename rti2 RTI
	  }
	   
	  
label var rti2 "RTI index"
label var offsh "Offshorability index"

gen offshwalt=.
label var offshwalt "Offshoring Potential (Blinder) from Walter"


sum isco08 if year~=2012

{
*replace iscoco=0 if isco08==9999
replace iscoco=110 if isco08==110
replace iscoco=110 if isco08==210
replace iscoco=110 if isco08==310
replace iscoco=110 if isco08==100
replace iscoco=110 if isco08==200
replace iscoco=110 if isco08==300
replace iscoco=1000 if isco08==1000
replace iscoco=1100 if isco08==1100
replace iscoco=1100 if isco08==1110
replace iscoco=1110 if isco08==1111
replace iscoco=1120 if isco08==1112
replace iscoco=1130 if isco08==1113
replace iscoco=1140 if isco08==1114
replace iscoco=1210 if isco08==1120
replace iscoco=1200 if isco08==1200
replace iscoco=1230 if isco08==1210
replace iscoco=1231 if isco08==1211
replace iscoco=1232 if isco08==1212
replace iscoco=1239 if isco08==1213
replace iscoco=1229 if isco08==1219
replace iscoco=1230 if isco08==1220
replace iscoco=1233 if isco08==1221
replace iscoco=1234 if isco08==1222
replace iscoco=1237 if isco08==1223
replace iscoco=1220 if isco08==1300
replace iscoco=1221 if isco08==1310
replace iscoco=1221 if isco08==1311
replace iscoco=1221 if isco08==1312
replace iscoco=1220 if isco08==1320
replace iscoco=1222 if isco08==1321
replace iscoco=1222 if isco08==1322
replace iscoco=1223 if isco08==1323
replace iscoco=1235 if isco08==1324
replace iscoco=1236 if isco08==1330
replace iscoco=1229 if isco08==1340
replace iscoco=1229 if isco08==1341
replace iscoco=1229 if isco08==1342
replace iscoco=1229 if isco08==1343
replace iscoco=1229 if isco08==1344
replace iscoco=1229 if isco08==1345
replace iscoco=1227 if isco08==1346
replace iscoco=1229 if isco08==1349
replace iscoco=1310 if isco08==1400
replace iscoco=1315 if isco08==1410
replace iscoco=1315 if isco08==1411
replace iscoco=1315 if isco08==1412
replace iscoco=1314 if isco08==1420
replace iscoco=1319 if isco08==1430
replace iscoco=1319 if isco08==1431
replace iscoco=1319 if isco08==1439
replace iscoco=2000 if isco08==2000
replace iscoco=2100 if isco08==2100
replace iscoco=2110 if isco08==2110
replace iscoco=2111 if isco08==2111
replace iscoco=2112 if isco08==2112
replace iscoco=2113 if isco08==2113
replace iscoco=2114 if isco08==2114
replace iscoco=2120 if isco08==2120
replace iscoco=2210 if isco08==2130
replace iscoco=2211 if isco08==2131
replace iscoco=2213 if isco08==2132
replace iscoco=2200 if isco08==2133
replace iscoco=2140 if isco08==2140
replace iscoco=2149 if isco08==2141
replace iscoco=2142 if isco08==2142
replace iscoco=2149 if isco08==2143
replace iscoco=2145 if isco08==2144
replace iscoco=2146 if isco08==2145
replace iscoco=2147 if isco08==2146
replace iscoco=2149 if isco08==2149
replace iscoco=2140 if isco08==2150
replace iscoco=2143 if isco08==2151
replace iscoco=2144 if isco08==2152
replace iscoco=2144 if isco08==2153
replace iscoco=2140 if isco08==2160
replace iscoco=2141 if isco08==2161
replace iscoco=2141 if isco08==2162
replace iscoco=3471 if isco08==2163
replace iscoco=2141 if isco08==2164
replace iscoco=2148 if isco08==2165
replace iscoco=3471 if isco08==2166
replace iscoco=2200 if isco08==2200
replace iscoco=2220 if isco08==2210
replace iscoco=2221 if isco08==2211
replace iscoco=2221 if isco08==2212
replace iscoco=2230 if isco08==2220
replace iscoco=2230 if isco08==2221
replace iscoco=2230 if isco08==2222
replace iscoco=3229 if isco08==2230
replace iscoco=3221 if isco08==2240
replace iscoco=2223 if isco08==2250
replace iscoco=3210 if isco08==2260
replace iscoco=2222 if isco08==2261
replace iscoco=2224 if isco08==2262
replace iscoco=2229 if isco08==2263
replace iscoco=3226 if isco08==2264
replace iscoco=3223 if isco08==2265
replace iscoco=3229 if isco08==2266
replace iscoco=3224 if isco08==2267
replace iscoco=2229 if isco08==2269
replace iscoco=2310 if isco08==2310
replace iscoco=2320 if isco08==2320
replace iscoco=2320 if isco08==2330
replace iscoco=2300 if isco08==2300
replace iscoco=2330 if isco08==2340
replace iscoco=2331 if isco08==2341
replace iscoco=2332 if isco08==2342
replace iscoco=2350 if isco08==2350
replace iscoco=2351 if isco08==2351
replace iscoco=2352 if isco08==2351
replace iscoco=2340 if isco08==2352
replace iscoco=2359 if isco08==2353
replace iscoco=2359 if isco08==2354
replace iscoco=2359 if isco08==2355
replace iscoco=2359 if isco08==2356
replace iscoco=2359 if isco08==2359
replace iscoco=2400 if isco08==2400
replace iscoco=2410 if isco08==2410
replace iscoco=2411 if isco08==2411
replace iscoco=2419 if isco08==2412
replace iscoco=2419 if isco08==2413
replace iscoco=2419 if isco08==2420
replace iscoco=2419 if isco08==2421
replace iscoco=2419 if isco08==2422
replace iscoco=2412 if isco08==2423
replace iscoco=2412 if isco08==2424
replace iscoco=2410 if isco08==2430
replace iscoco=2419 if isco08==2431
replace iscoco=2419 if isco08==2432
replace iscoco=3415 if isco08==2433
replace iscoco=3415 if isco08==2434
replace iscoco=2100 if isco08==2500
replace iscoco=2130 if isco08==2510
replace iscoco=2131 if isco08==2511
replace iscoco=2131 if isco08==2512
replace iscoco=2131 if isco08==2513
replace iscoco=2139 if isco08==2513
replace iscoco=2132 if isco08==2514
replace iscoco=2131 if isco08==2519
replace iscoco=2131 if isco08==2520
replace iscoco=2131 if isco08==2521
replace iscoco=2131 if isco08==2522
replace iscoco=2131 if isco08==2523
replace iscoco=2139 if isco08==2529
replace iscoco=2400 if isco08==2600
replace iscoco=2420 if isco08==2610
replace iscoco=2421 if isco08==2611
replace iscoco=2422 if isco08==2612
replace iscoco=2429 if isco08==2619
replace iscoco=2430 if isco08==2620
replace iscoco=2431 if isco08==2621
replace iscoco=2432 if isco08==2622
replace iscoco=2440 if isco08==2630
replace iscoco=2441 if isco08==2631
replace iscoco=2442 if isco08==2632
replace iscoco=2443 if isco08==2633
replace iscoco=2445 if isco08==2634
replace iscoco=2446 if isco08==2635
replace iscoco=2460 if isco08==2636
replace iscoco=2450 if isco08==2640
replace iscoco=2451 if isco08==2641
replace iscoco=2451 if isco08==2642
replace iscoco=2444 if isco08==2643
replace iscoco=2450 if isco08==2650
replace iscoco=2452 if isco08==2651
replace iscoco=2453 if isco08==2652
replace iscoco=2454 if isco08==2653
replace iscoco=2455 if isco08==2654
replace iscoco=2455 if isco08==2655
replace iscoco=3472 if isco08==2656
replace iscoco=3474 if isco08==2659
replace iscoco=3000 if isco08==3000
replace iscoco=3100 if isco08==3100
replace iscoco=3110 if isco08==3110
replace iscoco=3111 if isco08==3111
replace iscoco=3112 if isco08==3112
replace iscoco=3113 if isco08==3113
replace iscoco=3114 if isco08==3114
replace iscoco=3115 if isco08==3115
replace iscoco=3116 if isco08==3116
replace iscoco=3117 if isco08==3117
replace iscoco=3118 if isco08==3118
replace iscoco=3119 if isco08==3119
replace iscoco=1220 if isco08==3120
replace iscoco=1229 if isco08==3121
replace iscoco=1222 if isco08==3122
replace iscoco=1223 if isco08==3123
replace iscoco=8160 if isco08==3130
replace iscoco=8161 if isco08==3131
replace iscoco=8163 if isco08==3132
replace iscoco=8150 if isco08==3133
replace iscoco=8155 if isco08==3134
replace iscoco=8120 if isco08==3135
replace iscoco=8290 if isco08==3139
replace iscoco=3210 if isco08==3140
replace iscoco=3211 if isco08==3141
replace iscoco=3212 if isco08==3142
replace iscoco=3212 if isco08==3143
replace iscoco=3140 if isco08==3150
replace iscoco=3141 if isco08==3151
replace iscoco=3142 if isco08==3152
replace iscoco=3143 if isco08==3153
replace iscoco=3144 if isco08==3154
replace iscoco=3145 if isco08==3155
replace iscoco=3100 if isco08==3200
replace iscoco=3130 if isco08==3210
replace iscoco=3133 if isco08==3211
replace iscoco=3211 if isco08==3212
replace iscoco=3228 if isco08==3213
replace iscoco=7311 if isco08==3214
replace iscoco=3230 if isco08==3220
replace iscoco=3231 if isco08==3221
replace iscoco=3232 if isco08==3222
replace iscoco=3241 if isco08==3230
replace iscoco=3227 if isco08==3240
replace iscoco=3220 if isco08==3250
replace iscoco=3225 if isco08==3251
replace iscoco=3229 if isco08==3252
replace iscoco=3229 if isco08==3253
replace iscoco=3224 if isco08==3254
replace iscoco=3226 if isco08==3255
replace iscoco=3221 if isco08==3256
replace iscoco=3152 if isco08==3257
replace iscoco=3152 if isco08==3258
replace iscoco=3229 if isco08==3259
replace iscoco=3300 if isco08==3300
replace iscoco=3410 if isco08==3310
replace iscoco=3411 if isco08==3311
replace iscoco=3419 if isco08==3312
replace iscoco=3433 if isco08==3313
replace iscoco=3434 if isco08==3314
replace iscoco=3417 if isco08==3315
replace iscoco=3410 if isco08==3320
replace iscoco=3412 if isco08==3321
replace iscoco=3415 if isco08==3322
replace iscoco=3416 if isco08==3323
replace iscoco=3421 if isco08==3324
replace iscoco=3420 if isco08==3330
replace iscoco=3422 if isco08==3331
replace iscoco=3414 if isco08==3332
replace iscoco=3439 if isco08==3332
replace iscoco=3423 if isco08==3333
replace iscoco=3413 if isco08==3334
replace iscoco=3429 if isco08==3339
replace iscoco=3430 if isco08==3340
replace iscoco=3431 if isco08==3341
replace iscoco=3431 if isco08==3342
replace iscoco=3431 if isco08==3343
replace iscoco=3431 if isco08==3344
replace iscoco=3440 if isco08==3350
replace iscoco=3441 if isco08==3351
replace iscoco=3442 if isco08==3352
replace iscoco=3443 if isco08==3353
replace iscoco=3444 if isco08==3354
replace iscoco=3450 if isco08==3355
replace iscoco=3449 if isco08==3359
replace iscoco=3400 if isco08==3400
replace iscoco=3430 if isco08==3410
replace iscoco=3432 if isco08==3411
replace iscoco=3460 if isco08==3412
replace iscoco=3480 if isco08==3413
replace iscoco=3470 if isco08==3420
replace iscoco=3475 if isco08==3421
replace iscoco=3475 if isco08==3422
replace iscoco=3340 if isco08==3423
replace iscoco=3475 if isco08==3423
replace iscoco=3470 if isco08==3430
replace iscoco=3131 if isco08==3431
replace iscoco=3471 if isco08==3432
replace iscoco=3470 if isco08==3433
replace iscoco=5122 if isco08==3434
replace iscoco=3470 if isco08==3435
replace iscoco=3100 if isco08==3500
replace iscoco=3120 if isco08==3510
replace iscoco=3122 if isco08==3511
replace iscoco=3121 if isco08==3512
replace iscoco=2139 if isco08==3513
replace iscoco=3121 if isco08==3514
replace iscoco=3130 if isco08==3520
replace iscoco=3130 if isco08==3521
replace iscoco=3114 if isco08==3522
replace iscoco=3132 if isco08==3522
replace iscoco=4000 if isco08==4000
replace iscoco=4100 if isco08==4110
replace iscoco=4115 if isco08==4120
replace iscoco=4100 if isco08==4100
replace iscoco=4110 if isco08==4130
replace iscoco=4112 if isco08==4131
replace iscoco=4113 if isco08==4132
replace iscoco=4200 if isco08==4200
replace iscoco=4210 if isco08==4210
replace iscoco=4211 if isco08==4211
replace iscoco=4213 if isco08==4212
replace iscoco=4214 if isco08==4213
replace iscoco=4215 if isco08==4214
replace iscoco=4220 if isco08==4220
replace iscoco=3414 if isco08==4221
replace iscoco=4222 if isco08==4222
replace iscoco=4223 if isco08==4223
replace iscoco=4222 if isco08==4224
replace iscoco=4222 if isco08==4225
replace iscoco=4222 if isco08==4226
replace iscoco=4190 if isco08==4227
replace iscoco=4222 if isco08==4229
replace iscoco=4100 if isco08==4300
replace iscoco=4120 if isco08==4310
replace iscoco=4121 if isco08==4311
replace iscoco=4122 if isco08==4312
replace iscoco=4121 if isco08==4313
replace iscoco=4130 if isco08==4320
replace iscoco=4131 if isco08==4321
replace iscoco=4132 if isco08==4322
replace iscoco=4133 if isco08==4323
replace iscoco=4400 if isco08==4400
replace iscoco=4140 if isco08==4410
replace iscoco=4141 if isco08==4411
replace iscoco=4142 if isco08==4412
replace iscoco=4143 if isco08==4413
replace iscoco=4144 if isco08==4414
replace iscoco=4141 if isco08==4415
replace iscoco=4190 if isco08==4416
replace iscoco=4190 if isco08==4419
replace iscoco=5000 if isco08==5000
replace iscoco=5100 if isco08==5100
replace iscoco=5110 if isco08==5110
replace iscoco=5111 if isco08==5111
replace iscoco=5112 if isco08==5112
replace iscoco=5113 if isco08==5113
replace iscoco=5122 if isco08==5120
replace iscoco=5120 if isco08==5130
replace iscoco=5123 if isco08==5131
replace iscoco=5123 if isco08==5132
replace iscoco=5140 if isco08==5140
replace iscoco=5141 if isco08==5141
replace iscoco=5141 if isco08==5142
replace iscoco=5120 if isco08==5150
replace iscoco=5121 if isco08==5151
replace iscoco=5121 if isco08==5152
replace iscoco=9141 if isco08==5153
replace iscoco=5140 if isco08==5160
replace iscoco=5152 if isco08==5161
replace iscoco=5142 if isco08==5162
replace iscoco=5143 if isco08==5163
replace iscoco=5149 if isco08==5164
replace iscoco=3340 if isco08==5165
replace iscoco=5149 if isco08==5169
replace iscoco=5200 if isco08==5200
replace iscoco=5230 if isco08==5210
replace iscoco=5230 if isco08==5211
replace iscoco=9111 if isco08==5212
replace iscoco=1314 if isco08==5220
replace iscoco=1314 if isco08==5221
replace iscoco=1314 if isco08==5222
replace iscoco=5220 if isco08==5223
replace iscoco=4211 if isco08==5230
replace iscoco=5220 if isco08==5240
replace iscoco=5210 if isco08==5241
replace iscoco=5220 if isco08==5242
replace iscoco=9113 if isco08==5243
replace iscoco=9113 if isco08==5244
replace iscoco=5220 if isco08==5245
replace iscoco=5123 if isco08==5246
replace iscoco=5220 if isco08==5249
replace iscoco=5100 if isco08==5300
replace iscoco=5130 if isco08==5310
replace iscoco=5131 if isco08==5311
replace iscoco=5131 if isco08==5312
replace iscoco=5130 if isco08==5320
replace iscoco=5132 if isco08==5321
replace iscoco=5133 if isco08==5322
replace iscoco=5139 if isco08==5329
replace iscoco=5100 if isco08==5400
replace iscoco=5160 if isco08==5410
replace iscoco=5161 if isco08==5411
replace iscoco=5162 if isco08==5412
replace iscoco=5163 if isco08==5413
replace iscoco=5169 if isco08==5414
replace iscoco=5169 if isco08==5419
replace iscoco=6000 if isco08==6000
replace iscoco=6100 if isco08==6100
replace iscoco=6110 if isco08==6110
replace iscoco=6111 if isco08==6111
replace iscoco=6112 if isco08==6112
replace iscoco=6113 if isco08==6113
replace iscoco=6114 if isco08==6114
replace iscoco=6120 if isco08==6120
replace iscoco=6124 if isco08==6121
replace iscoco=6122 if isco08==6122
replace iscoco=6123 if isco08==6123
replace iscoco=6129 if isco08==6129
replace iscoco=6130 if isco08==6130
replace iscoco=6141 if isco08==6210
replace iscoco=6150 if isco08==6200
replace iscoco=6150 if isco08==6220
replace iscoco=6151 if isco08==6221
replace iscoco=6152 if isco08==6222
replace iscoco=6153 if isco08==6223
replace iscoco=6154 if isco08==6224
replace iscoco=6200 if isco08==6300
replace iscoco=6210 if isco08==6310
replace iscoco=6210 if isco08==6320
replace iscoco=6210 if isco08==6330
replace iscoco=6210 if isco08==6340
replace iscoco=7000 if isco08==7000
replace iscoco=7100 if isco08==7100
replace iscoco=7120 if isco08==7110
replace iscoco=7129 if isco08==7111
replace iscoco=7122 if isco08==7112
replace iscoco=7113 if isco08==7113
replace iscoco=7123 if isco08==7114
replace iscoco=7124 if isco08==7115
replace iscoco=7129 if isco08==7119
replace iscoco=7130 if isco08==7120
replace iscoco=7131 if isco08==7121
replace iscoco=7132 if isco08==7122
replace iscoco=7133 if isco08==7123
replace iscoco=7134 if isco08==7124
replace iscoco=7135 if isco08==7125
replace iscoco=7136 if isco08==7126
replace iscoco=7240 if isco08==7127
replace iscoco=7140 if isco08==7130
replace iscoco=7141 if isco08==7131
replace iscoco=7142 if isco08==7132
replace iscoco=7143 if isco08==7133
replace iscoco=7200 if isco08==7200
replace iscoco=7210 if isco08==7210
replace iscoco=7211 if isco08==7211
replace iscoco=7212 if isco08==7212
replace iscoco=7213 if isco08==7213
replace iscoco=7214 if isco08==7214
replace iscoco=7215 if isco08==7215
replace iscoco=7220 if isco08==7220
replace iscoco=7221 if isco08==7221
replace iscoco=7222 if isco08==7222
replace iscoco=7223 if isco08==7223
replace iscoco=7224 if isco08==7224
replace iscoco=7230 if isco08==7230
replace iscoco=7231 if isco08==7231
replace iscoco=7232 if isco08==7232
replace iscoco=7233 if isco08==7233
replace iscoco=7231 if isco08==7234
replace iscoco=7300 if isco08==7300
replace iscoco=7310 if isco08==7310
replace iscoco=7311 if isco08==7311
replace iscoco=7312 if isco08==7312
replace iscoco=7313 if isco08==7313
replace iscoco=7321 if isco08==7314
replace iscoco=7322 if isco08==7315
replace iscoco=3471 if isco08==7316
replace iscoco=7331 if isco08==7317
replace iscoco=7332 if isco08==7318
replace iscoco=7330 if isco08==7319
replace iscoco=7340 if isco08==7320
replace iscoco=7340 if isco08==7321
replace iscoco=7340 if isco08==7322
replace iscoco=7345 if isco08==7323
replace iscoco=7200 if isco08==7400
replace iscoco=7240 if isco08==7410
replace iscoco=7137 if isco08==7411
replace iscoco=7241 if isco08==7412
replace iscoco=7245 if isco08==7413
replace iscoco=7240 if isco08==7420
replace iscoco=7242 if isco08==7421
replace iscoco=7243 if isco08==7421
replace iscoco=7243 if isco08==7422
replace iscoco=7400 if isco08==7500
replace iscoco=7410 if isco08==7510
replace iscoco=7411 if isco08==7511
replace iscoco=7412 if isco08==7512
replace iscoco=7413 if isco08==7513
replace iscoco=7414 if isco08==7514
replace iscoco=7415 if isco08==7515
replace iscoco=7416 if isco08==7516
replace iscoco=7420 if isco08==7520
replace iscoco=7421 if isco08==7521
replace iscoco=7422 if isco08==7522
replace iscoco=7423 if isco08==7523
replace iscoco=7430 if isco08==7530
replace iscoco=7434 if isco08==7531
replace iscoco=7435 if isco08==7532
replace iscoco=7436 if isco08==7533
replace iscoco=7437 if isco08==7534
replace iscoco=7441 if isco08==7535
replace iscoco=7442 if isco08==7536
replace iscoco=7200 if isco08==7540
replace iscoco=7216 if isco08==7541
replace iscoco=7112 if isco08==7542
replace iscoco=3152 if isco08==7543
replace iscoco=7143 if isco08==7544
replace iscoco=7000 if isco08==7549
replace iscoco=8000 if isco08==8000
replace iscoco=8100 if isco08==8100
replace iscoco=8110 if isco08==8110
replace iscoco=7111 if isco08==8111
replace iscoco=8112 if isco08==8112
replace iscoco=8113 if isco08==8113
replace iscoco=8212 if isco08==8114
replace iscoco=8120 if isco08==8120
replace iscoco=8120 if isco08==8121
replace iscoco=8223 if isco08==8122
replace iscoco=8220 if isco08==8130
replace iscoco=8220 if isco08==8131
replace iscoco=8224 if isco08==8132
replace iscoco=8230 if isco08==8140
replace iscoco=8231 if isco08==8141
replace iscoco=8232 if isco08==8142
replace iscoco=8253 if isco08==8143
replace iscoco=8260 if isco08==8150
replace iscoco=8261 if isco08==8151
replace iscoco=8262 if isco08==8152
replace iscoco=8263 if isco08==8153
replace iscoco=8264 if isco08==8154
replace iscoco=8265 if isco08==8155
replace iscoco=8266 if isco08==8156
replace iscoco=8264 if isco08==8157
replace iscoco=8269 if isco08==8159
replace iscoco=8270 if isco08==8160
replace iscoco=8140 if isco08==8170
replace iscoco=8140 if isco08==8171
replace iscoco=8141 if isco08==8172
replace iscoco=8290 if isco08==8180
replace iscoco=8131 if isco08==8181
replace iscoco=8162 if isco08==8182
replace iscoco=8290 if isco08==8183
replace iscoco=8290 if isco08==8189
replace iscoco=8200 if isco08==8200
replace iscoco=8280 if isco08==8210
replace iscoco=8281 if isco08==8211
replace iscoco=8283 if isco08==8212
replace iscoco=8290 if isco08==8219
replace iscoco=8300 if isco08==8300
replace iscoco=8310 if isco08==8310
replace iscoco=8311 if isco08==8311
replace iscoco=8312 if isco08==8312
replace iscoco=8320 if isco08==8320
replace iscoco=8321 if isco08==8321
replace iscoco=8322 if isco08==8322
replace iscoco=8320 if isco08==8330
replace iscoco=8323 if isco08==8331
replace iscoco=8324 if isco08==8332
replace iscoco=8330 if isco08==8340
replace iscoco=8331 if isco08==8341
replace iscoco=8332 if isco08==8342
replace iscoco=8333 if isco08==8343
replace iscoco=8334 if isco08==8344
replace iscoco=8340 if isco08==8350
replace iscoco=9000 if isco08==9000
replace iscoco=9100 if isco08==9100
replace iscoco=9130 if isco08==9110
replace iscoco=9131 if isco08==9111
replace iscoco=9132 if isco08==9112
replace iscoco=9140 if isco08==9120
replace iscoco=9133 if isco08==9121
replace iscoco=9142 if isco08==9122
replace iscoco=9142 if isco08==9123
replace iscoco=9140 if isco08==9129
replace iscoco=9200 if isco08==9200
replace iscoco=9210 if isco08==9210
replace iscoco=9211 if isco08==9211
replace iscoco=9211 if isco08==9212
replace iscoco=9211 if isco08==9213
replace iscoco=9211 if isco08==9214
replace iscoco=9212 if isco08==9215
replace iscoco=9213 if isco08==9216
replace iscoco=9300 if isco08==9300
replace iscoco=9310 if isco08==9310
replace iscoco=9311 if isco08==9311
replace iscoco=9312 if isco08==9312
replace iscoco=9313 if isco08==9313
replace iscoco=9320 if isco08==9320
replace iscoco=9322 if isco08==9321
replace iscoco=9320 if isco08==9329
replace iscoco=9330 if isco08==9330
replace iscoco=9331 if isco08==9331
replace iscoco=9332 if isco08==9332
replace iscoco=9333 if isco08==9333
replace iscoco=9333 if isco08==9334
replace iscoco=9100 if isco08==9400
replace iscoco=9130 if isco08==9410
replace iscoco=5122 if isco08==9411
replace iscoco=9132 if isco08==9412
replace iscoco=9100 if isco08==9500
replace iscoco=9120 if isco08==9510
replace iscoco=9112 if isco08==9520
replace iscoco=9100 if isco08==9600
replace iscoco=9160 if isco08==9610
replace iscoco=9161 if isco08==9611
replace iscoco=9161 if isco08==9612
replace iscoco=9162 if isco08==9613
replace iscoco=9140 if isco08==9620
replace iscoco=9151 if isco08==9621
replace iscoco=9160 if isco08==9622
replace iscoco=9153 if isco08==9623
replace iscoco=9160 if isco08==9624
replace iscoco=9100 if isco08==9629
}

*/For below coding 1000: armed forces, should all be 100
replace iscoco=100 if inlist(isco08,0,100,110,200,210,300,310)

*/Missings etc.
replace iscoco = isco08 if iscoco==. & isco08>10000 & essround==6


** Here I include the Offshoring index from Walter, based on Blinder
{
replace offshwalt=0 if iscoco<.
replace offshwalt=49 if iscoco==1142
replace offshwalt=55 if iscoco==1222
replace offshwalt=28 if iscoco==1226
replace offshwalt=55 if iscoco==1228
replace offshwalt=83 if iscoco==1231
replace offshwalt=49 if iscoco==1232
replace offshwalt=40 if iscoco==1233
replace offshwalt=53 if iscoco==1234
replace offshwalt=49 if iscoco==1235
replace offshwalt=55 if iscoco==1236
replace offshwalt=55 if iscoco==1237
replace offshwalt=55 if iscoco==1311
replace offshwalt=55 if iscoco==1312
replace offshwalt=55 if iscoco==1313
replace offshwalt=55 if iscoco==1314
replace offshwalt=55 if iscoco==1315
replace offshwalt=48 if iscoco==1316
replace offshwalt=52 if iscoco==1317
replace offshwalt=55 if iscoco==1318
replace offshwalt=55 if iscoco==1319
replace offshwalt=66 if iscoco==2111
replace offshwalt=74 if iscoco==2112
replace offshwalt=66 if iscoco==2113
replace offshwalt=66 if iscoco==2114
replace offshwalt=89 if iscoco==2121
replace offshwalt=96 if iscoco==2122
replace offshwalt=83 if iscoco==2131
replace offshwalt=90 if iscoco==2139
replace offshwalt=25 if iscoco==2141
replace offshwalt=64 if iscoco==2143
replace offshwalt=74 if iscoco==2144
replace offshwalt=72 if iscoco==2146
replace offshwalt=69 if iscoco==2147
replace offshwalt=86 if iscoco==2148
replace offshwalt=71 if iscoco==2149
replace offshwalt=81 if iscoco==2211
replace offshwalt=83 if iscoco==2212
replace offshwalt=72 if iscoco==2411
replace offshwalt=50 if iscoco==2419
replace offshwalt=74 if iscoco==2421
replace offshwalt=67 if iscoco==2444
replace offshwalt=90 if iscoco==2451
replace offshwalt=78 if iscoco==2452
replace offshwalt=25 if iscoco==2453
replace offshwalt=48 if iscoco==2455
replace offshwalt=47 if iscoco==3111
replace offshwalt=47 if iscoco==3113
replace offshwalt=47 if iscoco==3114
replace offshwalt=72 if iscoco==3115
replace offshwalt=47 if iscoco==3116
replace offshwalt=94 if iscoco==3118
replace offshwalt=54 if iscoco==3119
replace offshwalt=75 if iscoco==3121
replace offshwalt=84 if iscoco==3122
replace offshwalt=68 if iscoco==3123
replace offshwalt=36 if iscoco==3131
replace offshwalt=36 if iscoco==3132
replace offshwalt=46 if iscoco==3133
replace offshwalt=34 if iscoco==3139
replace offshwalt=52 if iscoco==3141
replace offshwalt=60 if iscoco==3152
replace offshwalt=55 if iscoco==3211
replace offshwalt=55 if iscoco==3212
replace offshwalt=44 if iscoco==3213
replace offshwalt=32 if iscoco==3228
replace offshwalt=51 if iscoco==3411
replace offshwalt=85 if iscoco==3412
replace offshwalt=50 if iscoco==3414
replace offshwalt=55 if iscoco==3416
replace offshwalt=59 if iscoco==3419
replace offshwalt=51 if iscoco==3421
replace offshwalt=48 if iscoco==3422
replace offshwalt=38 if iscoco==3431
replace offshwalt=51 if iscoco==3432
replace offshwalt=84 if iscoco==3433
replace offshwalt=84 if iscoco==3434
replace offshwalt=54 if iscoco==3439
replace offshwalt=100 if iscoco==3442
replace offshwalt=85 if iscoco==3471
replace offshwalt=30 if iscoco==3472
replace offshwalt=95 if iscoco==4111
replace offshwalt=94 if iscoco==4112
replace offshwalt=100 if iscoco==4113
replace offshwalt=71 if iscoco==4114
replace offshwalt=38 if iscoco==4115
replace offshwalt=84 if iscoco==4121
replace offshwalt=54 if iscoco==4122
replace offshwalt=31 if iscoco==4131
replace offshwalt=67 if iscoco==4132
replace offshwalt=67 if iscoco==4133
replace offshwalt=46 if iscoco==4141
replace offshwalt=26 if iscoco==4142
replace offshwalt=95 if iscoco==4143
replace offshwalt=54 if iscoco==4144
replace offshwalt=54 if iscoco==4190
replace offshwalt=94 if iscoco==4211
replace offshwalt=54 if iscoco==4214
replace offshwalt=65 if iscoco==4215
replace offshwalt=72 if iscoco==4221
replace offshwalt=54 if iscoco==4222
replace offshwalt=50 if iscoco==4223
replace offshwalt=86 if iscoco==5113
replace offshwalt=59 if iscoco==6142
replace offshwalt=36 if iscoco==7111
replace offshwalt=35 if iscoco==7112
replace offshwalt=36 if iscoco==7113
replace offshwalt=65 if iscoco==7211
replace offshwalt=69 if iscoco==7212
replace offshwalt=70 if iscoco==7213
replace offshwalt=70 if iscoco==7222
replace offshwalt=68 if iscoco==7223
replace offshwalt=68 if iscoco==7224
replace offshwalt=26 if iscoco==7311
replace offshwalt=64 if iscoco==7313
replace offshwalt=69 if iscoco==7321
replace offshwalt=69 if iscoco==7322
replace offshwalt=68 if iscoco==7323
replace offshwalt=68 if iscoco==7324
replace offshwalt=60 if iscoco==7331
replace offshwalt=75 if iscoco==7332
replace offshwalt=59 if iscoco==7341
replace offshwalt=59 if iscoco==7342
replace offshwalt=59 if iscoco==7343
replace offshwalt=34 if iscoco==7344
replace offshwalt=59 if iscoco==7345
replace offshwalt=75 if iscoco==7346
replace offshwalt=68 if iscoco==7413
replace offshwalt=27 if iscoco==7414
replace offshwalt=55 if iscoco==7415
replace offshwalt=43 if iscoco==7421
replace offshwalt=57 if iscoco==7422
replace offshwalt=57 if iscoco==7423
replace offshwalt=66 if iscoco==7424
replace offshwalt=75 if iscoco==7431
replace offshwalt=75 if iscoco==7432
replace offshwalt=75 if iscoco==7433
replace offshwalt=73 if iscoco==7434
replace offshwalt=75 if iscoco==7435
replace offshwalt=75 if iscoco==7436
replace offshwalt=57 if iscoco==7437
replace offshwalt=75 if iscoco==7441
replace offshwalt=72 if iscoco==7442
replace offshwalt=36 if iscoco==8111
replace offshwalt=36 if iscoco==8112
replace offshwalt=36 if iscoco==8113
replace offshwalt=59 if iscoco==8121
replace offshwalt=68 if iscoco==8122
replace offshwalt=70 if iscoco==8123
replace offshwalt=68 if iscoco==8124
replace offshwalt=69 if iscoco==8131
replace offshwalt=68 if iscoco==8139
replace offshwalt=57 if iscoco==8141
replace offshwalt=68 if iscoco==8142
replace offshwalt=68 if iscoco==8143
replace offshwalt=68 if iscoco==8151
replace offshwalt=70 if iscoco==8152
replace offshwalt=68 if iscoco==8153
replace offshwalt=68 if iscoco==8154
replace offshwalt=29 if iscoco==8155
replace offshwalt=68 if iscoco==8159
replace offshwalt=42 if iscoco==8161
replace offshwalt=55 if iscoco==8162
replace offshwalt=29 if iscoco==8163
replace offshwalt=64 if iscoco==8171
replace offshwalt=68 if iscoco==8172
replace offshwalt=68 if iscoco==8211
replace offshwalt=68 if iscoco==8212
replace offshwalt=68 if iscoco==8221
replace offshwalt=35 if iscoco==8222
replace offshwalt=68 if iscoco==8223
replace offshwalt=41 if iscoco==8224
replace offshwalt=29 if iscoco==8229
replace offshwalt=69 if iscoco==8231
replace offshwalt=68 if iscoco==8232
replace offshwalt=57 if iscoco==8240
replace offshwalt=58 if iscoco==8251
replace offshwalt=59 if iscoco==8252
replace offshwalt=68 if iscoco==8253
replace offshwalt=75 if iscoco==8261
replace offshwalt=75 if iscoco==8262
replace offshwalt=75 if iscoco==8263
replace offshwalt=75 if iscoco==8264
replace offshwalt=75 if iscoco==8265
replace offshwalt=75 if iscoco==8266
replace offshwalt=75 if iscoco==8269
replace offshwalt=27 if iscoco==8271
replace offshwalt=68 if iscoco==8272
replace offshwalt=68 if iscoco==8273
replace offshwalt=30 if iscoco==8274
replace offshwalt=31 if iscoco==8275
replace offshwalt=68 if iscoco==8276
replace offshwalt=27 if iscoco==8277
replace offshwalt=68 if iscoco==8278
replace offshwalt=66 if iscoco==8281
replace offshwalt=66 if iscoco==8282
replace offshwalt=66 if iscoco==8283
replace offshwalt=68 if iscoco==8284
replace offshwalt=57 if iscoco==8285
replace offshwalt=64 if iscoco==8286
replace offshwalt=68 if iscoco==8290
replace offshwalt=34 if iscoco==8340
replace offshwalt=95 if iscoco==9113
replace offshwalt=64 if iscoco==9321
replace offshwalt=29 if iscoco==9333
replace offshwalt=55 if iscoco==1227
replace offshwalt=89 if iscoco==2121
replace offshwalt=100 if iscoco==2132
replace offshwalt=70 if iscoco==2145
replace offshwalt=71 if iscoco==2149
replace offshwalt=81 if iscoco==2211
replace offshwalt=46 if iscoco==2412
replace offshwalt=50 if iscoco==2419
replace offshwalt=33 if iscoco==2432
replace offshwalt=89 if iscoco==2441
replace offshwalt=48 if iscoco==2455
replace offshwalt=72 if iscoco==3115
replace offshwalt=54 if iscoco==3119
replace offshwalt=46 if iscoco==3133
replace offshwalt=34 if iscoco==3139
replace offshwalt=34 if iscoco==3224
replace offshwalt=51 if iscoco==3411
replace offshwalt=25 if iscoco==3415
replace offshwalt=50 if iscoco==3417
replace offshwalt=59 if iscoco==3419
replace offshwalt=51 if iscoco==3432
replace offshwalt=54 if iscoco==3439
replace offshwalt=90 if iscoco==3460
replace offshwalt=54 if iscoco==4122
replace offshwalt=31 if iscoco==4131
replace offshwalt=67 if iscoco==4132
replace offshwalt=46 if iscoco==4141
replace offshwalt=26 if iscoco==4142
replace offshwalt=54 if iscoco==4222
replace offshwalt=68 if iscoco==7141
replace offshwalt=68 if iscoco==7224
replace offshwalt=65 if iscoco==7241
replace offshwalt=34 if iscoco==7344
replace offshwalt=72 if iscoco==7442
replace offshwalt=68 if iscoco==8122
replace offshwalt=68 if iscoco==8139
replace offshwalt=42 if iscoco==8161
replace offshwalt=68 if iscoco==8211
replace offshwalt=68 if iscoco==8223
replace offshwalt=41 if iscoco==8224
replace offshwalt=57 if iscoco==8240
replace offshwalt=58 if iscoco==8251
replace offshwalt=75 if iscoco==8269
replace offshwalt=66 if iscoco==8281
replace offshwalt=66 if iscoco==8283
replace offshwalt=68 if iscoco==8284
replace offshwalt=68 if iscoco==8290
replace offshwalt=70 if iscoco==9322
}


********************************************************************
*********************** 6. Standardising income ********************
********************************************************************
*/ I build on code by Rueda and Theuwissen (2019) to standardize income 
*/ income deciles are coded into midpoints for each wave

gen income=.
replace income=900    	if hinctnt==1  // range Less than €1800, mid-point €900
replace income=2700   	if hinctnt==2  // range €1800 to under €3600, mid-point €2700
replace income=4800   	if hinctnt==3  // range €3600 to under €6000, mid-point €4800
replace income=9000   	if hinctnt==4  // range €6000 to under €12000, mid-point €9000
replace income=15000  	if hinctnt==5  // range €12000 to under €18000, mid-point €15000
replace income=21000  	if hinctnt==6  // range €18000 to under €24000, mid-point €21000
replace income=27000  	if hinctnt==7  // range €24000 to under €30000, mid-point €27000
replace income=33000  	if hinctnt==8  // range €30000 to under €36000, mid-point €33000
replace income=48000  	if hinctnt==9  // range €36000 to under €60000, mid-point €48000
replace income=75000  	if hinctnt==10 // range €60000 to under €90000, mid-point €75000
replace income=105000 	if hinctnt==11 // range €90000 to under €120000, mid-point €105000


*/Step 1c: ESS round 4
*/ Source: ESS Appendix A2: Income, ESS6-2008 ed. 2.0, national currency
*/ Greece and Austria is not included in the 2008 round no pt no ireland no italy

{
replace income= 1800		if hinctnta==1 & country==1&essround==4
replace income= 4800    	if hinctnta==2 & country==1&essround==4 
replace income= 9000    	if hinctnta==3 & country==1&essround==4 
replace income= 15000   	if hinctnta==4 & country==1&essround==4 
replace income= 21000   	if hinctnta==5 & country==1&essround==4 
replace income= 27000   	if hinctnta==6 & country==1&essround==4 
replace income= 33000   	if hinctnta==7 & country==1&essround==4
replace income= 48000    	if hinctnta==8 & country==1&essround==4
replace income= 75000   	if hinctnta==9 & country==1&essround==4
replace income= 2500		if hinctnta==1 & country==2&essround==4
replace income= 7500    	if hinctnta==2 & country==2&essround==4 
replace income= 11000   	if hinctnta==3 & country==2&essround==4 
replace income= 13000   	if hinctnta==4 & country==2&essround==4 
replace income= 15000   	if hinctnta==5 & country==2&essround==4
replace income= 17000   	if hinctnta==6 & country==2&essround==4 
replace income= 19500   	if hinctnta==7 & country==2&essround==4
replace income= 23500    	if hinctnta==8 & country==2&essround==4
replace income= 30500   	if hinctnta==9 & country==2&essround==4
replace income= 54999.5 	if hinctnta==1 & country==4&essround==4 
replace income= 128999		if hinctnta==2 & country==4&essround==4 
replace income= 166999.5  	if hinctnta==3 & country==4&essround==4 
replace income= 205999.5  	if hinctnta==4 & country==4&essround==4  
replace income= 251499.5  	if hinctnta==5 & country==4&essround==4 
replace income= 307499.5  	if hinctnta==6 & country==4&essround==4 
replace income= 365499.5  	if hinctnta==7 & country==4&essround==4  
replace income= 421499.5  	if hinctnta==8 & country==4&essround==4 
replace income= 491999.5  	if hinctnta==9 & country==4&essround==4 
replace income= 22800 		if hinctnta==1 & country==5&essround==4 
replace income= 50400    	if hinctnta==2 & country==5&essround==4 
replace income= 66600   	if hinctnta==3 & country==5&essround==4 
replace income= 85800    	if hinctnta==4 & country==5&essround==4  
replace income= 104400     	if hinctnta==5 & country==5&essround==4  
replace income= 127800      if hinctnta==6 & country==5&essround==4  
replace income= 154800   	if hinctnta==7 & country==5&essround==4 
replace income= 192600   	if hinctnta==8 & country==5&essround==4 
replace income= 253200 	    if hinctnta==9 & country==5&essround==4 
replace income= 5466 		if hinctnta==1 & country==6&essround==4 
replace income= 12522 		if hinctnta==2 & country==6&essround==4  
replace income= 16254		if hinctnta==3 & country==6&essround==4 
replace income= 20442   	if hinctnta==4 & country==6&essround==4 
replace income= 24828   	if hinctnta==5 & country==6&essround==4 
replace income= 30204   	if hinctnta==6 & country==6&essround==4 
replace income= 36744   	if hinctnta==7 & country==6&essround==4 
replace income= 44016   	if hinctnta==8 & country==6&essround==4 
replace income= 53868   	if hinctnta==9 & country==6&essround==4 
replace income= 5700 		if hinctnta==1 & country==7&essround==4 
replace income= 12900.5   	if hinctnta==2 & country==7&essround==4 
replace income= 16200   	if hinctnta==3 & country==7&essround==4 
replace income= 19500.5   	if hinctnta==4 & country==7&essround==4 
replace income= 22500.5   	if hinctnta==5 & country==7&essround==4 
replace income= 26000.5   	if hinctnta==6 & country==7&essround==4  
replace income= 30800.5   	if hinctnta==7 & country==7&essround==4 
replace income= 36600.5     if hinctnta==8 & country==7&essround==4 
replace income= 44400.5  	if hinctnta==9 & country==7&essround==4 
replace income= 6600  		if hinctnta==1 & country==8&essround==4  
replace income= 15350.5   	if hinctnta==2 & country==8&essround==4  
replace income= 19800.5   	if hinctnta==3 & country==8&essround==4  
replace income= 24550.5 	if hinctnta==4 & country==8&essround==4  
replace income= 29750.5   	if hinctnta==5 & country==8&essround==4 
replace income= 35400.5   	if hinctnta==6 & country==8&essround==4  
replace income= 41750.1  	if hinctnta==7 & country==8&essround==4 
replace income= 49900.5   	if hinctnta==8 & country==8&essround==4 
replace income= 62500.5  	if hinctnta==9 & country==8&essround==4   
replace income= 4275  		if hinctnta==1 & country==22&essround==4 
replace income= 10010   	if hinctnta==2 & country==22&essround==4 
replace income= 12995   	if hinctnta==3 & country==22&essround==4 
replace income= 15900   	if hinctnta==4 & country==22&essround==4  
replace income= 19290   	if hinctnta==5 & country==22&essround==4 
replace income= 23385    	if hinctnta==6 & country==22&essround==4 
replace income= 28260    	if hinctnta==7 & country==22&essround==4 
replace income= 34465    	if hinctnta==8 & country==22&essround==4  
replace income= 44085   	if hinctnta==9 & country==22&essround==4  
replace income= 48594 		if hinctnta==1 & country==20&essround==4 
replace income= 109794  	if hinctnta==2 & country==20&essround==4 
replace income= 135594  	if hinctnta==3 & country==20&essround==4 
replace income= 164394  	if hinctnta==4 & country==20&essround==4 
replace income= 196194  	if hinctnta==5 & country==20&essround==4 
replace income= 232194  	if hinctnta==6 & country==20&essround==4 
replace income= 283794  	if hinctnta==7 & country==20&essround==4 
replace income= 356394  	if hinctnta==8 & country==20&essround==4 
replace income= 445794  	if hinctnta==9 & country==20&essround==4 
replace income= 5849.5 		if hinctnta==1 & country==13&essround==4 
replace income= 13349.5   	if hinctnta==2 & country==13&essround==4 
replace income= 16599.5   	if hinctnta==3 & country==13&essround==4 
replace income= 19849.5   	if hinctnta==4 & country==13&essround==4 
replace income= 23399.5   	if hinctnta==5 & country==13&essround==4 
replace income= 27399.5  	if hinctnta==6 & country==13&essround==4 
replace income= 31849.5   	if hinctnta==7 & country==13&essround==4 
replace income= 37199.5   	if hinctnta==8 & country==13&essround==4 
replace income= 45249.5   	if hinctnta==9 & country==13&essround==4 
replace income= 7086.5 		if hinctnta==1 & country==11&essround==4 
replace income= 117474  	if hinctnta==2 & country==11&essround==4 
replace income= 23176   	if hinctnta==3 & country==11&essround==4 
replace income= 29177   	if hinctnta==4 & country==11&essround==4 
replace income= 35475.5  	if hinctnta==5 & country==11&essround==4 
replace income= 41906   	if hinctnta==6 & country==11&essround==4 
replace income= 50243.5  	if hinctnta==7 & country==11&essround==4 
replace income= 59901   	if hinctnta==8 & country==11&essround==4 
replace income= 75238.5 	if hinctnta==9 & country==11&essround==4 
replace income= 3000		if hinctnta==1 & country==9&essround==4
replace income= 7206    	if hinctnta==2 & country==9&essround==4 
replace income= 9606    	if hinctnta==3 & country==9&essround==4 
replace income= 11886   	if hinctnta==4 & country==9&essround==4 
replace income= 14286   	if hinctnta==5 & country==9&essround==4 
replace income= 17166    	if hinctnta==6 & country==9&essround==4 
replace income= 20766   	if hinctnta==7 & country==9&essround==4 
replace income= 25206    	if hinctnta==8 & country==9&essround==4 
replace income= 31806   	if hinctnta==9 & country==9&essround==4 
replace income=	54797.5	    if hinctnta==1 & country==3&essround==4 	 
replace income=	132973	    if hinctnta==2 & country==3&essround==4	 
replace income=	177675	    if hinctnta==3 & country==3&essround==4	 	 
replace income=	218314	    if hinctnta==4 & country==3&essround==4	 
replace income=	264536	    if hinctnta==5 & country==3&essround==4	 
replace income=	319786	    if hinctnta==6 & country==3&essround==4	 
replace income=	380377	    if hinctnta==7 & country==3&essround==4	 
replace income=	456633.5    if hinctnta==8 & country==3&essround==4	 
replace income=	576226	    if hinctnta==9 & country==3&essround==4	 
replace income=	2500		if hinctnta==1 & country==16&essround==4	 
replace income=	6000		if hinctnta==2 & country==16&essround==4	 
replace income=	8000		if hinctnta==3 & country==16&essround==4	 
replace income=	10000		if hinctnta==4 & country==16&essround==4	 
replace income=	12400		if hinctnta==5 & country==16&essround==4	 
replace income=	14900		if hinctnta==6 & country==16&essround==4	 
replace income=	17750		if hinctnta==7 & country==16&essround==4	 
replace income=	22000		if hinctnta==8 & country==16&essround==4	 
replace income=	29750		if hinctnta==9 & country==16&essround==4	 
replace income=	336000	    if hinctnta==1 & country==10&essround==4	 
replace income=	786006	    if hinctnta==2 & country==10&essround==4	
replace income=	1050006	    if hinctnta==3 & country==10&essround==4	
replace income=	1350006     if hinctnta==4 & country==10&essround==4	
replace income=	1650006	    if hinctnta==5 & country==10&essround==4	
replace income=	1950006	    if hinctnta==6 & country==10&essround==4	
replace income=	2250006	    if hinctnta==7 & country==10&essround==4	
replace income=	2550006	    if hinctnta==8 & country==10&essround==4	
replace income=	3150006	    if hinctnta==9 & country==10&essround==4	
replace income=	5855    	if hinctnta==1 & country==12&essround==4	
replace income=	13671.5   	if hinctnta==2 & country==12&essround==4	
replace income=	17416.5	    if hinctnta==3 & country==12&essround==4	
replace income=	21118	    if hinctnta==4 & country==12&essround==4	
replace income=	25018	    if hinctnta==5 & country==12&essround==4	
replace income=	29476.5	    if hinctnta==6 & country==12&essround==4	
replace income=	34817.5	    if hinctnta==7 & country==12&essround==4	
replace income=	41511	    if hinctnta==8 & country==12&essround==4	
replace income=	51944.5	    if hinctnta==9 & country==12&essround==4	
replace income=	5000	    if hinctnta==1 & country==15&essround==4	
replace income=	11500	    if hinctnta==2 & country==15&essround==4	
replace income=	15000	    if hinctnta==3 & country==15&essround==4	
replace income=	18500	    if hinctnta==4 & country==15&essround==4	
replace income=	22000	    if hinctnta==5 & country==15&essround==4	
replace income=	26000	    if hinctnta==6 & country==15&essround==4	
replace income=	30000	    if hinctnta==7 & country==15&essround==4	
replace income=	35000	    if hinctnta==8 & country==15&essround==4	
replace income=	40000	    if hinctnta==9 & country==15&essround==4	
replace income=	3900	    if hinctnta==1 & country==18&essround==4	
replace income=	8694	    if hinctnta==2 & country==18&essround==4	
replace income=	10494	    if hinctnta==3 & country==18&essround==4	
replace income=	12294	    if hinctnta==4 & country==18&essround==4	
replace income=	14394	    if hinctnta==5 & country==18&essround==4	
replace income=	17394	    if hinctnta==6 & country==18&essround==4	
replace income=	20994	    if hinctnta==7 & country==18&essround==4	
replace income=	24594	    if hinctnta==8 & country==18&essround==4	
replace income=	31194	    if hinctnta==9 & country==18&essround==4	
replace income=	2112	    if hinctnta==1 & country==17&essround==4
replace income=	5094	    if hinctnta==2 & country==17&essround==4	
replace income=	6744	    if hinctnta==3 & country==17&essround==4	
replace income=	8352	    if hinctnta==4 & country==17&essround==4	
replace income=	10104	    if hinctnta==5 & country==17&essround==4	
replace income=	12084	    if hinctnta==6 & country==17&essround==4	
replace income=	14328	    if hinctnta==7 & country==17&essround==4	
replace income=	17076	    if hinctnta==8 & country==17&essround==4	
replace income=	22392	    if hinctnta==9 & country==17&essround==4	
replace income=	4000	    if hinctnta==1 & country==19&essround==4
replace income=	9500	    if hinctnta==2 & country==19&essround==4	
replace income=	12500	    if hinctnta==3 & country==19&essround==4	
replace income=	15500	    if hinctnta==4 & country==19&essround==4	
replace income=	18500	    if hinctnta==5 & country==19&essround==4	
replace income=	21500	    if hinctnta==6 & country==19&essround==4	
replace income=	25000	    if hinctnta==7 & country==19&essround==4	
replace income=	30000	    if hinctnta==8 & country==19&essround==4	
replace income=	37000	    if hinctnta==9 & country==19&essround==4

}

*/Step 1d: ESS round 5
*/ Source: ESS Appendix A2: Income, ESS6-2010 ed. 2.0, national currency
*/ Greece and Austria is not included in the 2010 round
{
replace income= 5520 		if hinctnta==1 & country==2&essround==5
replace income= 12600   	if hinctnta==2 & country==2&essround==5 
replace income= 15900   	if hinctnta==3 & country==2&essround==5 
replace income= 19500   	if hinctnta==4 & country==2&essround==5 
replace income= 23460   	if hinctnta==5 & country==2&essround==5 
replace income= 28080   	if hinctnta==6 & country==2&essround==5 
replace income= 34020   	if hinctnta==7 & country==2&essround==5
replace income= 41160    	if hinctnta==8 & country==2&essround==5
replace income= 50820   	if hinctnta==9 & country==2&essround==5
replace income= 60500 		if hinctnta==1 & country==4&essround==5 
replace income= 140500		if hinctnta==2 & country==4&essround==5 
replace income= 179500  	if hinctnta==3 & country==4&essround==5  
replace income= 220500  	if hinctnta==4 & country==4&essround==5  
replace income= 270000  	if hinctnta==5 & country==4&essround==5 
replace income= 331000  	if hinctnta==6 & country==4&essround==5 
replace income= 394000  	if hinctnta==7 & country==4&essround==5  
replace income= 455000  	if hinctnta==8 & country==4&essround==5 
replace income= 532000  	if hinctnta==9 & country==4&essround==5 
replace income= 5754 		if hinctnta==1 & country==6&essround==5 
replace income= 13140 		if hinctnta==2 & country==6&essround==5  
replace income= 17076		if hinctnta==3 & country==6&essround==5 
replace income= 21510   	if hinctnta==4 & country==6&essround==5 
replace income= 26040   	if hinctnta==5 & country==6&essround==5 
replace income= 31536   	if hinctnta==6 & country==6&essround==5 
replace income= 38220   	if hinctnta==7 & country==6&essround==5 
replace income= 45858   	if hinctnta==8 & country==6&essround==5 
replace income= 55806   	if hinctnta==9 & country==6&essround==5 
replace income= 6600 		if hinctnta==1 & country==7&essround==5 
replace income= 15000   	if hinctnta==2 & country==7&essround==5 
replace income= 18900   	if hinctnta==3 & country==7&essround==5 
replace income= 23100   	if hinctnta==4 & country==7&essround==5 
replace income= 27600   	if hinctnta==5 & country==7&essround==5 
replace income= 32400   	if hinctnta==6 & country==7&essround==5  
replace income= 37200   	if hinctnta==7 & country==7&essround==5 
replace income= 43800  	    if hinctnta==8 & country==7&essround==5 
replace income= 54600   	if hinctnta==9 & country==7&essround==5 
replace income= 5670  		if hinctnta==1 & country==8&essround==5  
replace income= 13380   	if hinctnta==2 & country==8&essround==5  
replace income= 17185   	if hinctnta==3 & country==8&essround==5  
replace income= 20790 	    if hinctnta==4 & country==8&essround==5  
replace income= 24565   	if hinctnta==5 & country==8&essround==5 
replace income= 28600   	if hinctnta==6 & country==8&essround==5  
replace income= 33205   	if hinctnta==7 & country==8&essround==5 
replace income= 39045   	if hinctnta==8 & country==8&essround==5 
replace income= 48075   	if hinctnta==9 & country==8&essround==5  
replace income= 4000 		if hinctnta==1 & country==5&essround==5 
replace income= 9500    	if hinctnta==2 & country==5&essround==5 
replace income= 12500   	if hinctnta==3 & country==5&essround==5 
replace income= 15509    	if hinctnta==4 & country==5&essround==5  
replace income= 18500     	if hinctnta==5 & country==5&essround==5  
replace income= 21500       if hinctnta==6 & country==5&essround==5  
replace income= 25000   	if hinctnta==7 & country==5&essround==5 
replace income= 30000   	if hinctnta==8 & country==5&essround==5 
replace income= 37000 	    if hinctnta==9 & country==5&essround==5  
replace income= 4695   		if hinctnta==1 & country==22&essround==5 
replace income= 10950   	if hinctnta==2 & country==22&essround==5 
replace income= 14050   	if hinctnta==3 & country==22&essround==5 
replace income= 17235   	if hinctnta==4 & country==22&essround==5  
replace income= 20910   	if hinctnta==5 & country==22&essround==5 
replace income= 25235    	if hinctnta==6 & country==22&essround==5 
replace income= 30295    	if hinctnta==7 & country==22&essround==5 
replace income= 37075    	if hinctnta==8 & country==22&essround==5  
replace income= 47505   	if hinctnta==9 & country==22&essround==5  
replace income= 69000 		if hinctnta==1 & country==20&essround==5 
replace income= 153000  	if hinctnta==2 & country==20&essround==5 
replace income= 186000  	if hinctnta==3 & country==20&essround==5 
replace income= 222000  	if hinctnta==4 & country==20&essround==5 
replace income= 264000  	if hinctnta==5 & country==20&essround==5 
replace income= 312000  	if hinctnta==6 & country==20&essround==5 
replace income= 360000  	if hinctnta==7 & country==20&essround==5 
replace income= 408000  	if hinctnta==8 & country==20&essround==5 
replace income= 480000  	if hinctnta==9 & country==20&essround==5 
replace income= 6600 		if hinctnta==1 & country==13&essround==5 
replace income= 15100   	if hinctnta==2 & country==13&essround==5 
replace income= 18750   	if hinctnta==3 & country==13&essround==5 
replace income= 22350   	if hinctnta==4 & country==13&essround==5 
replace income= 26400    	if hinctnta==5 & country==13&essround==5 
replace income= 31050   	if hinctnta==6 & country==13&essround==5 
replace income= 36300   	if hinctnta==7 & country==13&essround==5 
replace income= 42750   	if hinctnta==8 & country==13&essround==5 
replace income= 49600   	if hinctnta==9 & country==13&essround==5 
replace income= 7086.5 		if hinctnta==1 & country==11&essround==5 
replace income= 117474  	if hinctnta==2 & country==11&essround==5 
replace income= 23176   	if hinctnta==3 & country==11&essround==5 
replace income= 29177   	if hinctnta==4 & country==11&essround==5 
replace income= 35475.5  	if hinctnta==5 & country==11&essround==5 
replace income= 41906   	if hinctnta==6 & country==11&essround==5 
replace income= 50243.5  	if hinctnta==7 & country==11&essround==5 
replace income= 59901   	if hinctnta==8 & country==11&essround==5 
replace income= 75238.5 	if hinctnta==9 & country==11&essround==5 
replace income= 3450		if hinctnta==1 & country==9&essround==5 
replace income= 8100    	if hinctnta==2 & country==9&essround==5 
replace income= 10530    	if hinctnta==3 & country==9&essround==5 
replace income= 13020    	if hinctnta==4 & country==9&essround==5 
replace income= 15690   	if hinctnta==5 & country==9&essround==5 
replace income= 18750    	if hinctnta==6 & country==9&essround==5 
replace income= 22440   	if hinctnta==7 & country==9&essround==5 
replace income= 27440    	if hinctnta==8 & country==9&essround==5 
replace income= 34380   	if hinctnta==9 & country==9&essround==5 
replace income=	58224	    if hinctnta==9 & country==9&essround==5 	 
replace income=	134124	    if hinctnta==2 & country==3&essround==5	 
replace income=	176334	    if hinctnta==3 & country==3&essround==5	 	 
replace income=	217242	    if hinctnta==4 & country==3&essround==5	 
replace income=	254310	    if hinctnta==5 & country==3&essround==5	 
replace income=	299496	    if hinctnta==6 & country==3&essround==5	 
replace income=	349890	    if hinctnta==7 & country==3&essround==5	 
replace income=	407934	    if hinctnta==8 & country==3&essround==5	 
replace income=	498432	    if hinctnta==9 & country==3&essround==5	 
replace income=	2750		if hinctnta==1 & country==16&essround==5	 
replace income=	6500.5		if hinctnta==2 & country==16&essround==5	 
replace income=	8750.5		if hinctnta==3 & country==16&essround==5	 
replace income=	11000.5		if hinctnta==4 & country==16&essround==5	 
replace income=	13000.5		if hinctnta==5 & country==16&essround==5	 
replace income=	15500.5		if hinctnta==6 & country==16&essround==5	 
replace income=	18500.5		if hinctnta==7 & country==16&essround==5	 
replace income=	22500.5		if hinctnta==8 & country==16&essround==5	 
replace income=	30000.5		if hinctnta==9 & country==16&essround==5	 
replace income=	1614	    if hinctnta==1 & country==5&essround==5	 
replace income=	3534	    if hinctnta==2 & country==5&essround==5	 
replace income=	4374	    if hinctnta==3 & country==5&essround==5	 
replace income=	5694	    if hinctnta==4 & country==5&essround==5	 
replace income=	7074	    if hinctnta==5 & country==5&essround==5	 
replace income=	8454	    if hinctnta==6 & country==5&essround==5	 
replace income=	10494	    if hinctnta==7 & country==5&essround==5	 
replace income=	12894	    if hinctnta==8 & country==5&essround==5	 
replace income=	16794	    if hinctnta==9 & country==5&essround==5	 
replace income=	431994	    if hinctnta==1 & country==10&essround==5	 
replace income=	972000	    if hinctnta==2 & country==10&essround==5	
replace income=	1200006	    if hinctnta==3 & country==10&essround==5	
replace income=	1470006	    if hinctnta==4 & country==10&essround==5	
replace income=	1770006	    if hinctnta==5 & country==10&essround==5	
replace income=	2010006	    if hinctnta==6 & country==10&essround==5	
replace income=	2250006	    if hinctnta==7 & country==10&essround==5	
replace income=	2700006	    if hinctnta==8 & country==10&essround==5	
replace income=	3180006	    if hinctnta==9 & country==10&essround==5	
replace income=	5855    	if hinctnta==1 & country==12&essround==5	
replace income=	13671.5   	if hinctnta==2 & country==12&essround==5	
replace income=	17416.5	    if hinctnta==3 & country==12&essround==5	
replace income=	21118	    if hinctnta==4 & country==12&essround==5	
replace income=	25018	    if hinctnta==5 & country==12&essround==5	
replace income=	29476.5	    if hinctnta==6 & country==12&essround==5	
replace income=	34817.5	    if hinctnta==7 & country==12&essround==5	
replace income=	41511	    if hinctnta==8 & country==12&essround==5	
replace income=	51944.5	    if hinctnta==9 & country==12&essround==5	
replace income=	7200	    if hinctnta==1 & country==15&essround==5	
replace income=	16806	    if hinctnta==2 & country==15&essround==5	
replace income=	21606	    if hinctnta==3 & country==15&essround==5	
replace income=	27006	    if hinctnta==4 & country==15&essround==5	
replace income=	33006	    if hinctnta==5 & country==15&essround==5	
replace income=	39006	    if hinctnta==6 & country==15&essround==5	
replace income=	45606	    if hinctnta==7 & country==15&essround==5	
replace income=	54006	    if hinctnta==8 & country==15&essround==5	
replace income=	67806	    if hinctnta==9 & country==15&essround==5	
replace income=	3300	    if hinctnta==1 & country==18&essround==5	
replace income=	8106	    if hinctnta==2 & country==18&essround==5	
replace income=	10806	    if hinctnta==3 & country==18&essround==5	
replace income=	13806	    if hinctnta==4 & country==18&essround==5	
replace income=	17406	    if hinctnta==5 & country==18&essround==5	
replace income=	21006	    if hinctnta==6 & country==18&essround==5	
replace income=	24606	    if hinctnta==7 & country==18&essround==5	
replace income=	28206	    if hinctnta==8 & country==18&essround==5	
replace income=	33606	    if hinctnta==9 & country==18&essround==5	
replace income=	2112	    if hinctnta==1 & country==17&essround==5	
replace income=	5094	    if hinctnta==2 & country==17&essround==5	
replace income=	6744	    if hinctnta==3 & country==17&essround==5	
replace income=	8352	    if hinctnta==4 & country==17&essround==5	
replace income=	10104	    if hinctnta==5 & country==17&essround==5	
replace income=	12084	    if hinctnta==6 & country==17&essround==5	
replace income=	14328	    if hinctnta==7 & country==17&essround==5	
replace income=	17076	    if hinctnta==8 & country==17&essround==5	
replace income=	22392	    if hinctnta==9 & country==17&essround==5	
replace income=	4200	    if hinctnta==1 & country==19&essround==5	
replace income=	9600	    if hinctnta==2 & country==19&essround==5	
replace income=	12600	    if hinctnta==3 & country==19&essround==5	
replace income=	15600	    if hinctnta==4 & country==19&essround==5	
replace income=	18600	    if hinctnta==5 & country==19&essround==5	
replace income=	21600	    if hinctnta==6 & country==19&essround==5	
replace income=	25200	    if hinctnta==7 & country==19&essround==5	
replace income=	30000	    if hinctnta==8 & country==19&essround==5	
replace income=	37200	    if hinctnta==9 & country==19&essround==5	
}

*/Step 1d: ESS round 6
*/ Source: ESS Appendix A2: Income, ESS6-2012 ed. 2.0, national currency
*/ Greece and Austria is not included in the 2012 round
{
replace income= 6059.5 		if hinctnta==1 & country==2&essround==6
replace income= 13724.5 	if hinctnta==2 & country==2&essround==6
replace income= 17104.5 	if hinctnta==3 & country==2&essround==6
replace income= 20799.5 	if hinctnta==4 & country==2&essround==6
replace income= 25009.5 	if hinctnta==5 & country==2&essround==6
replace income= 30364.5 	if hinctnta==6 & country==2&essround==6
replace income= 36839.5 	if hinctnta==7 & country==2&essround==6
replace income= 44124.5 	if hinctnta==8 & country==2&essround==6
replace income= 54114.5 	if hinctnta==9 & country==2&essround==6
replace income=	58224	    if hinctnta==1 & country==3&essround==6 
replace income=	134124	    if hinctnta==2 & country==3&essround==6
replace income=	176334	    if hinctnta==3 & country==3&essround==6	 
replace income=	217242	    if hinctnta==4 & country==3&essround==6	 
replace income=	254310	    if hinctnta==5 & country==3&essround==6
replace income=	299496	    if hinctnta==6 & country==3&essround==6 
replace income=	349890	    if hinctnta==7 & country==3&essround==6
replace income=	407934	    if hinctnta==8 & country==3&essround==6 
replace income=	498432	    if hinctnta==9 & country==3&essround==6
replace income= 66000 		if hinctnta==1 & country==4&essround==6
replace income= 153000 		if hinctnta==2 & country==4&essround==6
replace income= 195499.5	if hinctnta==3 & country==4&essround==6
replace income= 240499.5 	if hinctnta==4 & country==4&essround==6
replace income= 294499.5 	if hinctnta==5 & country==4&essround==6
replace income= 360499.5	if hinctnta==6 & country==4&essround==6
replace income= 428999.5	if hinctnta==7 & country==4&essround==6
replace income= 495999.5 	if hinctnta==8 & country==4&essround==6
replace income= 579999.5 	if hinctnta==9 & country==4&essround==6
replace income= 6054 		if hinctnta==1 & country==6&essround==6
replace income= 13806.5		if hinctnta==2 & country==6&essround==6
replace income= 17916.5		if hinctnta==3 & country==6&essround==6
replace income= 22584.5 	if hinctnta==4 & country==6&essround==6
replace income= 27294.5 	if hinctnta==5 & country==6&essround==6
replace income= 32790.5 	if hinctnta==6 & country==6&essround==6
replace income= 39618.5 	if hinctnta==7 & country==6&essround==6
replace income= 47568.5 	if hinctnta==8 & country==6&essround==6
replace income= 58032.5 	if hinctnta==9 & country==6&essround==6
replace income= 6600 		if hinctnta==1 & country==7&essround==6
replace income= 15600.5 	if hinctnta==2 & country==7&essround==6
replace income= 19800.5 	if hinctnta==3 & country==7&essround==6
replace income= 23400.5 	if hinctnta==4 & country==7&essround==6
replace income= 27600.5 	if hinctnta==5 & country==7&essround==6
replace income= 33000.5 	if hinctnta==6 & country==7&essround==6
replace income= 39000.5 	if hinctnta==7 & country==7&essround==6
replace income= 45600.5 	if hinctnta==8 & country==7&essround==6
replace income= 56400.5 	if hinctnta==9 & country==7&essround==6
replace income= 5880 		if hinctnta==1 & country==8&essround==6
replace income= 13980.5 	if hinctnta==2 & country==8&essround==6
replace income= 18060.5 	if hinctnta==3 & country==8&essround==6
replace income= 21900.5 	if hinctnta==4 & country==8&essround==6
replace income= 25980.5 	if hinctnta==5 & country==8&essround==6
replace income= 30420.5 	if hinctnta==6 & country==8&essround==6
replace income= 35580.5 	if hinctnta==7 & country==8&essround==6
replace income= 42120.5 	if hinctnta==8 & country==8&essround==6
replace income= 51960.5 	if hinctnta==9 & country==8&essround==6
replace income= 4560 		if hinctnta==1 & country==19&essround==6
replace income= 11520.5 	if hinctnta==2 & country==19&essround==6
replace income= 14520.5 	if hinctnta==3 & country==19&essround==6
replace income= 17400.5 	if hinctnta==4 & country==19&essround==6
replace income= 20340.5 	if hinctnta==5 & country==19&essround==6
replace income= 23340.5 	if hinctnta==6 & country==19&essround==6
replace income= 27240.5 	if hinctnta==7 & country==19&essround==6
replace income= 30960.5 	if hinctnta==8 & country==19&essround==6
replace income= 38760.5 	if hinctnta==9 & country==19&essround==6
replace income= 4914 		if hinctnta==1 & country==22&essround==6
replace income= 11388.5 	if hinctnta==2 & country==22&essround==6
replace income= 14508.5 	if hinctnta==3 & country==22&essround==6
replace income= 17888.5 	if hinctnta==4 & country==22&essround==6
replace income= 21528.5 	if hinctnta==5 & country==22&essround==6
replace income= 25688.5 	if hinctnta==6 & country==22&essround==6
replace income= 30888.5 	if hinctnta==7 & country==22&essround==6
replace income= 37388.5 	if hinctnta==8 & country==22&essround==6
replace income= 48048.5 	if hinctnta==9 & country==22&essround==6
replace income= 65994 		if hinctnta==1 & country==20&essround==6
replace income= 155988.5 	if hinctnta==2 & country==20&essround==6
replace income= 203988.5 	if hinctnta==3 & country==20&essround==6
replace income= 245988.5 	if hinctnta==4 & country==20&essround==6
replace income= 281988.5 	if hinctnta==5 & country==20&essround==6
replace income= 323988.5 	if hinctnta==6 & country==20&essround==6
replace income= 371988.5 	if hinctnta==7 & country==20&essround==6
replace income= 437988.5 	if hinctnta==8 & country==20&essround==6
replace income= 533988.5 	if hinctnta==9 & country==20&essround==6
replace income= 6500 		if hinctnta==1 & country==13&essround==6
replace income= 15000.5 	if hinctnta==2 & country==13&essround==6
replace income= 18700.5 	if hinctnta==3 & country==13&essround==6
replace income= 22250.5 	if hinctnta==4 & country==13&essround==6
replace income= 26250.5 	if hinctnta==5 & country==13&essround==6
replace income= 30950.5 	if hinctnta==6 & country==13&essround==6
replace income= 36300.5 	if hinctnta==7 & country==13&essround==6
replace income= 42750.5 	if hinctnta==8 & country==13&essround==6
replace income= 52600.5 	if hinctnta==9 & country==13&essround==6
replace income= 6786 		if hinctnta==1 & country==11&essround==6
replace income= 15704.5 	if hinctnta==2 & country==11&essround==6
replace income= 21190.5 	if hinctnta==3 & country==11&essround==6
replace income= 27274.5 	if hinctnta==4 & country==11&essround==6
replace income= 32838.5 	if hinctnta==5 & country==11&essround==6
replace income= 39000.5 	if hinctnta==6 & country==11&essround==6
replace income= 47060.5 	if hinctnta==7 & country==11&essround==6
replace income= 57278.5 	if hinctnta==8 & country==11&essround==6
replace income= 73294.5 	if hinctnta==9 & country==11&essround==6 
replace income=	2750		if hinctnta==1 & country==16&essround==6
replace income=	6500.5		if hinctnta==2 & country==16&essround==6
replace income=	8750.5		if hinctnta==3 & country==16&essround==6
replace income=	11000.5		if hinctnta==4 & country==16&essround==6
replace income=	13000.5		if hinctnta==5 & country==16&essround==6
replace income=	15500.5		if hinctnta==6 & country==16&essround==6
replace income=	18500.5		if hinctnta==7 & country==16&essround==6
replace income=	22500.5		if hinctnta==8 & country==16&essround==6
replace income=	30000.5		if hinctnta==9 & country==16&essround==6
replace income=	1614	    if hinctnta==1 & country==5&essround==6
replace income=	3534	    if hinctnta==2 & country==5&essround==6	
replace income=	4374	    if hinctnta==3 & country==5&essround==6
replace income=	5694	    if hinctnta==4 & country==5&essround==6
replace income=	7074	    if hinctnta==5 & country==5&essround==6
replace income=	8454	    if hinctnta==6 & country==5&essround==6	 
replace income=	10494	    if hinctnta==7 & country==5&essround==6	 
replace income=	12894	    if hinctnta==8 & country==5&essround==6
replace income=	16794	    if hinctnta==9 & country==5&essround==6
replace income=	431994	    if hinctnta==1 & country==10&essround==6
replace income=	972000	    if hinctnta==2 & country==10&essround==6
replace income=	1200006	    if hinctnta==3 & country==10&essround==6	 
replace income=	1470006	    if hinctnta==4 & country==10&essround==6	 
replace income=	1770006	    if hinctnta==5 & country==10&essround==6
replace income=	2010006	    if hinctnta==6 & country==10&essround==6
replace income=	2250006	    if hinctnta==7 & country==10&essround==6
replace income=	2700006	    if hinctnta==8 & country==10&essround==6
replace income=	3180006	    if hinctnta==9 & country==10&essround==6 
replace income=	5855    	if hinctnta==1 & country==12&essround==6	 
replace income=	13671.5   	if hinctnta==2 & country==12&essround==6	 
replace income=	17416.5	    if hinctnta==3 & country==12&essround==6	 
replace income=	21118	    if hinctnta==4 & country==12&essround==6	 
replace income=	25018	    if hinctnta==5 & country==12&essround==6	 
replace income=	29476.5	    if hinctnta==6 & country==12&essround==6	 
replace income=	34817.5	    if hinctnta==7 & country==12&essround==6	 
replace income=	41511	    if hinctnta==8 & country==12&essround==6	 
replace income=	51944.5	    if hinctnta==9 & country==12&essround==6	 
replace income=	7200	    if hinctnta==1 & country==15&essround==6	 
replace income=	16806	    if hinctnta==2 & country==15&essround==6	 
replace income=	21606	    if hinctnta==3 & country==15&essround==6	 
replace income=	27006	    if hinctnta==4 & country==15&essround==6	 
replace income=	33006	    if hinctnta==5 & country==15&essround==6	 
replace income=	39006	    if hinctnta==6 & country==15&essround==6	 
replace income=	45606	    if hinctnta==7 & country==15&essround==6	 
replace income=	54006	    if hinctnta==8 & country==15&essround==6	 
replace income=	67806	    if hinctnta==9 & country==15&essround==6	 
replace income=	3300	    if hinctnta==1 & country==18&essround==6	 
replace income=	8106	    if hinctnta==2 & country==18&essround==6	 	 
replace income=	10806	    if hinctnta==3 & country==18&essround==6	 	 
replace income=	13806	    if hinctnta==4 & country==18&essround==6	 
replace income=	17406	    if hinctnta==5 & country==18&essround==6	 
replace income=	21006	    if hinctnta==6 & country==18&essround==6	 
replace income=	24606	    if hinctnta==7 & country==18&essround==6	 	 
replace income=	28206	    if hinctnta==8 & country==18&essround==6	 	 
replace income=	33606	    if hinctnta==9 & country==18&essround==6	 
replace income=	2112	    if hinctnta==1 & country==17&essround==6	 	 
replace income=	5094	    if hinctnta==2 & country==17&essround==6 
replace income=	6744	    if hinctnta==3 & country==17&essround==6
replace income=	8352	    if hinctnta==4 & country==17&essround==6
replace income=	10104	    if hinctnta==5 & country==17&essround==6	 
replace income=	12084	    if hinctnta==6 & country==17&essround==6
replace income=	14328	    if hinctnta==7 & country==17&essround==6
replace income=	17076	    if hinctnta==8 & country==17&essround==6
replace income=	22392	    if hinctnta==9 & country==17&essround==6
}

*/Step 1f: ESS round 7 
*/ Source: ESS Appendix A2: Income, ESS&-2014, national currency (DE+Hung annual) no Slovakia or greece or italy + DK
{
replace income= 6300 		if hinctnta==1 & country==1&essround==7
replace income= 15350  	    if hinctnta==2 & country==1&essround==7
replace income= 20450   	if hinctnta==3 & country==1&essround==7
replace income= 24950   	if hinctnta==4 & country==1&essround==7
replace income= 29950   	if hinctnta==5 & country==1&essround==7
replace income= 35850   	if hinctnta==6 & country==1&essround==7
replace income= 42250   	if hinctnta==7 & country==1&essround==7
replace income= 50250   	if hinctnta==8 & country==1&essround==7
replace income= 62850   	if hinctnta==9 & country==1&essround==7
replace income= 6280 		if hinctnta==1 & country==2&essround==7
replace income= 13330 	    if hinctnta==2 & country==2&essround==7
replace income= 17290   	if hinctnta==3 & country==2&essround==7
replace income= 21180   	if hinctnta==4 & country==2&essround==7
replace income= 25600   	if hinctnta==5 & country==2&essround==7
replace income= 30950   	if hinctnta==6 & country==2&essround==7
replace income= 37390   	if hinctnta==7 & country==2&essround==7
replace income= 45340   	if hinctnta==8 & country==2&essround==7
replace income= 56080   	if hinctnta==9 & country==2&essround==7
replace income=	68669.5		if hinctnta==1 & country==3&essround==7
replace income=	157199.5	if hinctnta==2 & country==3&essround==7
replace income=	204599.5	if hinctnta==3 & country==3&essround==7
replace income=	250800  	if hinctnta==4 & country==3&essround==7
replace income=	289199.5 	if hinctnta==5 & country==3&essround==7
replace income=	335400 	    if hinctnta==6 & country==3&essround==7
replace income=	368700  	if hinctnta==7 & country==3&essround==7
replace income=	460199.5 	if hinctnta==8 & country==3&essround==7
replace income=	560400  	if hinctnta==9 & country==3&essround==7
replace income= 66000 		if hinctnta==1 & country==4&essround==7
replace income= 152999 		if hinctnta==2 & country==4&essround==7
replace income= 195499.5	if hinctnta==3 & country==4&essround==7
replace income= 240499.5 	if hinctnta==4 & country==4&essround==7
replace income= 294499.5 	if hinctnta==5 & country==4&essround==7
replace income= 361500  	if hinctnta==6 & country==4&essround==7
replace income= 429500  	if hinctnta==7 & country==4&essround==7 
replace income= 497000  	if hinctnta==8 & country==4&essround==7
replace income= 581000  	if hinctnta==9 & country==4&essround==7
replace income=	2500		if hinctnta==1 & country==5&essround==7
replace income=	7700    	if hinctnta==2 & country==5&essround==7
replace income=	11200   	if hinctnta==3 & country==5&essround==7
replace income=	12750   	if hinctnta==4 & country==5&essround==7
replace income=	15750   	if hinctnta==5 & country==5&essround==7
replace income=	19000 	    if hinctnta==6 & country==5&essround==7
replace income=	21500   	if hinctnta==7 & country==5&essround==7
replace income=	25000   	if hinctnta==8 & country==5&essround==7
replace income=	31000   	if hinctnta==9 & country==5&essround==7
replace income= 6450 		if hinctnta==1 & country==6&essround==7
replace income= 14652   	if hinctnta==2 & country==6&essround==7
replace income= 19050   	if hinctnta==3 & country==6&essround==7
replace income= 24138   	if hinctnta==4 & country==6&essround==7
replace income= 29058   	if hinctnta==5 & country==6&essround==7
replace income= 34710   	if hinctnta==6 & country==6&essround==7
replace income= 41981    	if hinctnta==7 & country==6&essround==7
replace income= 50280   	if hinctnta==8 & country==6&essround==7
replace income= 61374    	if hinctnta==9 & country==6&essround==7
replace income= 6600 		if hinctnta==1 & country==7&essround==7
replace income= 15120   	if hinctnta==2 & country==7&essround==7
replace income= 16890.5  	if hinctnta==3 & country==7&essround==7
replace income= 22590.5     if hinctnta==4 & country==7&essround==7
replace income= 27000       if hinctnta==5 & country==7&essround==7
replace income= 31980.5    	if hinctnta==6 & country==7&essround==7
replace income= 37690.5 	if hinctnta==7 & country==7&essround==7
replace income= 45000       if hinctnta==8 & country==7&essround==7
replace income= 56400.5 	if hinctnta==9 & country==7&essround==7
replace income= 5600		if hinctnta==1 & country==8&essround==7
replace income= 14286   	if hinctnta==2 & country==8&essround==7
replace income= 18486 	    if hinctnta==3 & country==8&essround==7
replace income= 22446    	if hinctnta==4 & country==8&essround==7
replace income= 26646   	if hinctnta==5 & country==8&essround==7
replace income= 31200   	if hinctnta==6 & country==8&essround==7
replace income= 36480   	if hinctnta==7 & country==8&essround==7
replace income= 43146    	if hinctnta==8 & country==8&essround==7
replace income= 53226   	if hinctnta==9 & country==8&essround==7
replace income= 432000		if hinctnta==1 & country==10&essround==7
replace income= 972006  	if hinctnta==2 & country==10&essround==7
replace income= 1200006 	if hinctnta==3 & country==10&essround==7
replace income= 1470006 	if hinctnta==4 & country==10&essround==7
replace income= 1770006 	if hinctnta==5 & country==10&essround==7
replace income= 2010012 	if hinctnta==6 & country==10&essround==7
replace income= 2250006 	if hinctnta==7 & country==10&essround==7
replace income= 2700006 	if hinctnta==8 & country==10&essround==7
replace income= 3180006 	if hinctnta==9 & country==10&essround==7
replace income= 4482		if hinctnta==1 & country==19&essround==7
replace income= 10031 	    if hinctnta==2 & country==19&essround==7
replace income= 12870   	if hinctnta==3 & country==19&essround==7
replace income= 15720   	if hinctnta==4 & country==19&essround==7
replace income= 18708   	if hinctnta==5 & country==19&essround==7
replace income= 22908   	if hinctnta==6 & country==19&essround==7
replace income= 26473   	if hinctnta==7 & country==19&essround==7
replace income= 30378   	if hinctnta==8 & country==19&essround==7
replace income= 37842   	if hinctnta==9 & country==19&essround==7
replace income= 5824 		if hinctnta==1 & country==22&essround==7
replace income= 13440   	if hinctnta==2 & country==22&essround==7
replace income= 17360   	if hinctnta==3 & country==22&essround==7
replace income= 21420   	if hinctnta==4 & country==22&essround==7
replace income= 25620   	if hinctnta==5 & country==22&essround==7
replace income= 30520   	if hinctnta==6 & country==22&essround==7
replace income= 36260    	if hinctnta==7 & country==22&essround==7
replace income= 43764   	if hinctnta==8 & country==22&essround==7
replace income= 55496   	if hinctnta==9 & country==22&essround==7 
replace income= 65994 		if hinctnta==1 & country==20&essround==7
replace income= 155994 	    if hinctnta==2 & country==20&essround==7
replace income= 203994  	if hinctnta==3 & country==20&essround==7
replace income= 245994  	if hinctnta==4 & country==20&essround==7
replace income= 281994  	if hinctnta==5 & country==20&essround==7
replace income= 323994   	if hinctnta==6 & country==20&essround==7
replace income= 371994  	if hinctnta==7 & country==20&essround==7
replace income= 437994   	if hinctnta==8 & country==20&essround==7 
replace income= 533994  	if hinctnta==9 & country==20&essround==7
replace income= 6500 		if hinctnta==1 & country==13&essround==7
replace income= 15000   	if hinctnta==2 & country==13&essround==7
replace income= 18750   	if hinctnta==3 & country==13&essround==7
replace income= 22350   	if hinctnta==4 & country==13&essround==7
replace income= 26350   	if hinctnta==5 & country==13&essround==7
replace income= 31000   	if hinctnta==6 & country==13&essround==7
replace income= 36350   	if hinctnta==7 & country==13&essround==7
replace income= 42800   	if hinctnta==8 & country==13&essround==7
replace income= 52300   	if hinctnta==9 & country==13&essround==7
replace income= 6888 		if hinctnta==1 & country==11&essround==7
replace income= 16408    	if hinctnta==2 & country==11&essround==7
replace income= 22204    	if hinctnta==3 & country==11&essround==7
replace income= 28196   	if hinctnta==4 & country==11&essround==7
replace income= 33544   	if hinctnta==5 & country==11&essround==7
replace income= 39732   	if hinctnta==6 & country==11&essround==7
replace income= 47628    	if hinctnta==7 & country==11&essround==7
replace income= 57540   	if hinctnta==8 & country==11&essround==7
replace income= 72044   	if hinctnta==9 & country==11&essround==7
replace income=	2549.5		if hinctnta==1 & country==16&essround==7
replace income=	6250 		if hinctnta==2 & country==16&essround==7
replace income=	8400.5		if hinctnta==3 & country==16&essround==7
replace income=	10500.5		if hinctnta==4 & country==16&essround==7
replace income=	12800.5		if hinctnta==5 & country==16&essround==7
replace income=	15375.5		if hinctnta==6 & country==16&essround==7
replace income=	18425.5		if hinctnta==7 & country==16&essround==7
replace income=	22500.5		if hinctnta==8 & country==16&essround==7
replace income=	31350.5		if hinctnta==9 & country==16&essround==7
replace income=	7800		if hinctnta==1 & country==15&essround==7
replace income=	18006 		if hinctnta==2 & country==15&essround==7
replace income=	23406		if hinctnta==3 & country==15&essround==7
replace income=	29406		if hinctnta==4 & country==15&essround==7
replace income=	34806		if hinctnta==5 & country==15&essround==7
replace income=	40806		if hinctnta==6 & country==15&essround==7
replace income=	48006		if hinctnta==7 & country==15&essround==7
replace income=	56406		if hinctnta==8 & country==15&essround==7
replace income=	70206		if hinctnta==9 & country==15&essround==7
replace income=	2549.5		if hinctnta==1 & country==18&essround==7
replace income=	6250 		if hinctnta==2 & country==18&essround==7
replace income=	8400.5		if hinctnta==3 & country==18&essround==7
replace income=	10500.5		if hinctnta==4 & country==18&essround==7
replace income=	12800.5		if hinctnta==5 & country==18&essround==7
replace income=	15375.5		if hinctnta==6 & country==18&essround==7
replace income=	18425.5		if hinctnta==7 & country==18&essround==7
replace income=	22500.5		if hinctnta==8 & country==18&essround==7
replace income=	31350.5		if hinctnta==9 & country==18&essround==7
replace income=	2549.5		if hinctnta==1 & country==17&essround==7
replace income=	6250 		if hinctnta==2 & country==17&essround==7
replace income=	8400.5		if hinctnta==3 & country==17&essround==7
replace income=	10500.5		if hinctnta==4 & country==17&essround==7
replace income=	12800.5		if hinctnta==5 & country==17&essround==7 
replace income=	15375.5		if hinctnta==6 & country==17&essround==7
replace income=	18425.5		if hinctnta==7 & country==17&essround==7
replace income=	22500.5		if hinctnta==8 & country==17&essround==7
replace income=	31350.5		if hinctnta==9 & country==17&essround==7 
replace	income=3000		    if hinctnta==1 & country==9&essround==7
replace	income=7200		    if hinctnta==2 & country==9&essround==7
replace	income=9600		    if hinctnta==3 & country==9&essround==7
replace	income=11880	    if hinctnta==4 & country==9&essround==7
replace	income=14280	    if hinctnta==5 & country==9&essround==7
replace	income=17160	    if hinctnta==6 & country==9&essround==7
replace	income=20760	    if hinctnta==7 & country==9&essround==7
replace	income=25200	    if hinctnta==8 & country==9&essround==7
replace	income=31800	    if hinctnta==9 & country==9&essround==7
replace income=	5855	    if hinctnta==1 & country==12&essround==7
replace income=	13671.5	    if hinctnta==2 & country==12&essround==7
replace income=	17416.5	    if hinctnta==3 & country==12&essround==7
replace income=	21118	    if hinctnta==4 & country==12&essround==7
replace income=	25018	    if hinctnta==5 & country==12&essround==7
replace income=	29476.5	    if hinctnta==6 & country==12&essround==7 
replace income=	34817.5	    if hinctnta==7 & country==12&essround==7
replace income=	41511	    if hinctnta==8 & country==12&essround==7
replace income=	51944.5	    if hinctnta==9 & country==12&essround==7
}

*/Step 1g: ESS round 8 
*/ Source: ESS Appendix A2: Income, ESS&-2016, national currency (DE+Hung annual) no Slovakia, greece
{
replace income= 7400 		if hinctnta==1 & country==1&essround==8
replace income= 17300 	    if hinctnta==2 & country==1&essround==8
replace income= 22000   	if hinctnta==3 & country==1&essround==8
replace income= 26800   	if hinctnta==4 & country==1&essround==8
replace income= 35000   	if hinctnta==5 & country==1&essround==8
replace income= 41000   	if hinctnta==6 & country==1&essround==8 
replace income= 48000   	if hinctnta==7 & country==1&essround==8
replace income= 56500   	if hinctnta==8 & country==1&essround==8
replace income= 70700   	if hinctnta==9 & country==1&essround==8
replace income= 6695		if hinctnta==1 & country==2&essround==8 
replace income= 15120 	    if hinctnta==2 & country==2&essround==8 
replace income= 18750   	if hinctnta==3 & country==2&essround==8 
replace income= 22930   	if hinctnta==4 & country==2&essround==8 
replace income= 27735   	if hinctnta==5 & country==2&essround==8  
replace income= 33480   	if hinctnta==6 & country==2&essround==8 
replace income= 40785   	if hinctnta==7 & country==2&essround==8 
replace income= 49600   	if hinctnta==8 & country==2&essround==8 
replace income= 60665   	if hinctnta==9 & country==2&essround==8 
replace income=	70649.5		if hinctnta==1 & country==3&essround==8 
replace income=	162549.5	if hinctnta==2 & country==3&essround==8 
replace income=	211449.5	if hinctnta==3 & country==3&essround==8 
replace income=	260299.5  	if hinctnta==4 & country==3&essround==8 
replace income=	304649.5 	if hinctnta==5 & country==3&essround==8 
replace income=	355949.5 	if hinctnta==6 & country==3&essround==8 
replace income=	419149.5  	if hinctnta==7 & country==3&essround==8 
replace income=	494449.5 	if hinctnta==8 & country==3&essround==8 
replace income=	603099.5  	if hinctnta==9 & country==3&essround==8 
replace income= 66000 		if hinctnta==1 & country==4&essround==8 
replace income= 152999 		if hinctnta==2 & country==4&essround==8 
replace income= 195499.5	if hinctnta==3 & country==4&essround==8 
replace income= 240499.5 	if hinctnta==4 & country==4&essround==8 
replace income= 294499.5 	if hinctnta==5 & country==4&essround==8 
replace income= 361500  	if hinctnta==6 & country==4&essround==8 
replace income= 429500  	if hinctnta==7 & country==4&essround==8 
replace income= 497000  	if hinctnta==8 & country==4&essround==8 
replace income= 581000  	if hinctnta==9 & country==4&essround==8 
replace income=	2299.5		if hinctnta==1 & country==5&essround==8 
replace income=	6099    	if hinctnta==2 & country==5&essround==8 
replace income=	8649.5   	if hinctnta==3 & country==5&essround==8 
replace income=	11099.5   	if hinctnta==4 & country==5&essround==8 
replace income=	13749.5   	if hinctnta==5 & country==5&essround==8 
replace income=	16499.5 	if hinctnta==6 & country==5&essround==8 
replace income=	19999.5   	if hinctnta==7 & country==5&essround==8 
replace income=	24499.5   	if hinctnta==8 & country==5&essround==8 
replace income=	31499.5   	if hinctnta==9 & country==5&essround==8 
replace income= 6690		if hinctnta==1 & country==6&essround==8 
replace income= 14946    	if hinctnta==2 & country==6&essround==8 
replace income= 18756   	if hinctnta==3 & country==6&essround==8 
replace income= 23490   	if hinctnta==4 & country==6&essround==8 
replace income= 28872   	if hinctnta==5 & country==6&essround==8 
replace income= 35148   	if hinctnta==6 & country==6&essround==8 
replace income= 42312   	if hinctnta==7 & country==6&essround==8 
replace income= 50526   	if hinctnta==8 & country==6&essround==8 
replace income= 61740    	if hinctnta==9 & country==6&essround==8 
replace income= 6775		if hinctnta==1 & country==7&essround==8 
replace income= 15475.5   	if hinctnta==2 & country==7&essround==8 
replace income= 19295.5  	if hinctnta==3 & country==7&essround==8 
replace income= 23225.5     if hinctnta==4 & country==7&essround==8 
replace income= 27700.5     if hinctnta==5 & country==7&essround==8 
replace income= 32725.5    	if hinctnta==6 & country==7&essround==8 
replace income= 38650.5 	if hinctnta==7 & country==7&essround==8 
replace income= 46150.5     if hinctnta==8 & country==7&essround==8 
replace income= 57800.5 	if hinctnta==9 & country==7&essround==8 
replace income= 6355		if hinctnta==1 & country==8&essround==8 
replace income= 15000.5   	if hinctnta==2 & country==8&essround==8 
replace income= 19375.5     if hinctnta==3 & country==8&essround==8 
replace income= 23560.5    	if hinctnta==4 & country==8&essround==8 
replace income= 27970.5   	if hinctnta==5 & country==8&essround==8  
replace income= 32890.5  	if hinctnta==6 & country==8&essround==8 
replace income= 38575.5  	if hinctnta==7 & country==8&essround==8  
replace income= 45715.5    	if hinctnta==8 & country==8&essround==8 
replace income= 56415.5  	if hinctnta==9 & country==8&essround==8 
replace income= 750000		if hinctnta==1 & country==10&essround==8 
replace income= 1692000  	if hinctnta==2 & country==10&essround==8
replace income= 2022000 	if hinctnta==3 & country==10&essround==8
replace income= 2346000 	if hinctnta==4 & country==10&essround==8
replace income= 2706000 	if hinctnta==5 & country==10&essround==8
replace income= 2976000 	if hinctnta==6 & country==10&essround==8
replace income= 3336000 	if hinctnta==7 & country==10&essround==8
replace income= 4086000 	if hinctnta==8 & country==10&essround==8
replace income= 4686000 	if hinctnta==9 & country==10&essround==8
replace income= 4482		if hinctnta==1 & country==19&essround==8
replace income= 10031 	    if hinctnta==2 & country==19&essround==8
replace income= 12870   	if hinctnta==3 & country==19&essround==8
replace income= 15720   	if hinctnta==4 & country==19&essround==8
replace income= 18708   	if hinctnta==5 & country==19&essround==8
replace income= 22908   	if hinctnta==6 & country==19&essround==8 
replace income= 26473   	if hinctnta==7 & country==19&essround==8
replace income= 30378   	if hinctnta==8 & country==19&essround==8
replace income= 37842   	if hinctnta==9 & country==19&essround==8
replace income= 6160		if hinctnta==1 & country==22&essround==8
replace income= 14420  	    if hinctnta==2 & country==22&essround==8
replace income= 18508   	if hinctnta==3 & country==22&essround==8
replace income= 22624    	if hinctnta==4 & country==22&essround==8
replace income= 27132   	if hinctnta==5 & country==22&essround==8
replace income= 32396   	if hinctnta==6 & country==22&essround==8
replace income= 38668    	if hinctnta==7 & country==22&essround==8
replace income= 46704   	if hinctnta==8 & country==22&essround==8
replace income= 59668   	if hinctnta==9 & country==22&essround==8
replace income= 71994 		if hinctnta==1 & country==20&essround==8
replace income= 167994	    if hinctnta==2 & country==20&essround==8
replace income= 215994  	if hinctnta==3 & country==20&essround==8
replace income= 263994  	if hinctnta==4 & country==20&essround==8
replace income= 305994  	if hinctnta==5 & country==20&essround==8
replace income= 347994   	if hinctnta==6 & country==20&essround==8
replace income= 401994      if hinctnta==7 & country==20&essround==8
replace income= 473994   	if hinctnta==8 & country==20&essround==8
replace income= 575994  	if hinctnta==9 & country==20&essround==8
replace income= 6600 		if hinctnta==1 & country==13&essround==8
replace income= 15250   	if hinctnta==2 & country==13&essround==8
replace income= 19050   	if hinctnta==3 & country==13&essround==8
replace income= 22650   	if hinctnta==4 & country==13&essround==8
replace income= 26600   	if hinctnta==5 & country==13&essround==8
replace income= 31300   	if hinctnta==6 & country==13&essround==8
replace income= 37000   	if hinctnta==7 & country==13&essround==8 
replace income= 43950   	if hinctnta==8 & country==13&essround==8
replace income= 53950   	if hinctnta==9 & country==13&essround==8
replace income= 6806 		if hinctnta==1 & country==11&essround==8
replace income= 16940    	if hinctnta==2 & country==11&essround==8
replace income= 23520   	if hinctnta==3 & country==11&essround==8
replace income= 29960   	if hinctnta==4 & country==11&essround==8
replace income= 36120   	if hinctnta==5 & country==11&essround==8
replace income= 42560  	    if hinctnta==6 & country==11&essround==8
replace income= 49700    	if hinctnta==7 & country==11&essround==8
replace income= 59780 	    if hinctnta==8 & country==11&essround==8
replace income= 78400   	if hinctnta==9 & country==11&essround==8
replace income= 4500 		if hinctnta==1 & country==12&essround==8
replace income= 11250    	if hinctnta==2 & country==12&essround==8
replace income= 15250.5   	if hinctnta==3 & country==12&essround==8
replace income= 18750.5  	if hinctnta==4 & country==12&essround==8
replace income= 22250.5   	if hinctnta==5 & country==12&essround==8
replace income= 26500.5  	if hinctnta==6 & country==12&essround==8
replace income= 31750.5    	if hinctnta==7 & country==12&essround==8
replace income= 38500.5 	if hinctnta==8 & country==12&essround==8
replace income= 48500.5   	if hinctnta==9 & country==12&essround==8
replace income=	2480		if hinctnta==1 & country==16&essround==8
replace income=	6080.5 		if hinctnta==2 & country==16&essround==8
replace income=	8200.5		if hinctnta==3 & country==16&essround==8
replace income=	10300.5		if hinctnta==4 & country==16&essround==8
replace income=	12650.5		if hinctnta==5 & country==16&essround==8
replace income=	15200.5		if hinctnta==6 & country==16&essround==8
replace income=	18100.5		if hinctnta==7 & country==16&essround==8
replace income=	22075.5		if hinctnta==8 & country==16&essround==8
replace income=	30725.5		if hinctnta==9 & country==16&essround==8
replace income=	8400		if hinctnta==1 & country==15&essround==8
replace income=	19806 		if hinctnta==2 & country==15&essround==8
replace income=	25806		if hinctnta==3 & country==15&essround==8
replace income=	31806		if hinctnta==4 & country==15&essround==8
replace income=	37806		if hinctnta==5 & country==15&essround==8
replace income=	44406		if hinctnta==6 & country==15&essround==8
replace income=	52206		if hinctnta==7 & country==15&essround==8
replace income=	61806		if hinctnta==8 & country==15&essround==8
replace income=	76206		if hinctnta==9 & country==15&essround==8
replace income=	3300		if hinctnta==1 & country==18&essround==8
replace income=	8100 		if hinctnta==2 & country==18&essround==8
replace income=	10800		if hinctnta==3 & country==18&essround==8
replace income=	13800		if hinctnta==4 & country==18&essround==8
replace income=	17400		if hinctnta==5 & country==18&essround==8
replace income=	21000		if hinctnta==6 & country==18&essround==8
replace income=	24600       if hinctnta==7 & country==18&essround==8
replace income=	28800		if hinctnta==8 & country==18&essround==8
replace income=	34800		if hinctnta==9 & country==18&essround==8
replace income=	2549.5		if hinctnta==1 & country==17&essround==8
replace income=	6250 		if hinctnta==2 & country==17&essround==8
replace income=	8400.5		if hinctnta==3 & country==17&essround==8
replace income=	10500.5		if hinctnta==4 & country==17&essround==8
replace income=	12800.5		if hinctnta==5 & country==17&essround==8
replace income=	15375.5		if hinctnta==6 & country==17&essround==8
replace income=	18425.5		if hinctnta==7 & country==17&essround==8
replace income=	22500.5		if hinctnta==8 & country==17&essround==8
replace income=	31350.5		if hinctnta==9 & country==17&essround==8 
replace	income=3000		    if hinctnta==1 & country==9&essround==8
replace	income=7200		    if hinctnta==2 & country==9&essround==8
replace	income=9600		    if hinctnta==3 & country==9&essround==8
replace	income=11880	    if hinctnta==4 & country==9&essround==8
replace	income=14280	    if hinctnta==5 & country==9&essround==8
replace	income=17160	    if hinctnta==6 & country==9&essround==8
replace	income=20760	    if hinctnta==7 & country==9&essround==8
replace	income=25200	    if hinctnta==8 & country==9&essround==8
replace	income=31800	    if hinctnta==9 & country==9&essround==8
}

*/Step 1h: ESS round 9 
*/ Source: ESS Appendix A2: Income, ESS&-2018, national currency (DE+Hung annual) no Slovakia, greece
{
replace income= 7650		if hinctnta==1 & country==1&essround==9
replace income= 18200 	    if hinctnta==2 & country==1&essround==9
replace income= 23900   	if hinctnta==3 & country==1&essround==9
replace income= 28350   	if hinctnta==4 & country==1&essround==9
replace income= 34050   	if hinctnta==5 & country==1&essround==9
replace income= 40150    	if hinctnta==6 & country==1&essround==9
replace income= 47300   	if hinctnta==7 & country==1&essround==9
replace income= 56000   	if hinctnta==8 & country==1&essround==9
replace income= 69050   	if hinctnta==9 & country==1&essround==9
replace income= 7150		if hinctnta==1 & country==2&essround==9
replace income= 16150 	    if hinctnta==2 & country==2&essround==9
replace income= 20050    	if hinctnta==3 & country==2&essround==9
replace income= 24550   	if hinctnta==4 & country==2&essround==9
replace income= 29700   	if hinctnta==5 & country==2&essround==9
replace income= 31350   	if hinctnta==6 & country==2&essround==9
replace income= 43700   	if hinctnta==7 & country==2&essround==9
replace income= 53150   	if hinctnta==8 & country==2&essround==9
replace income= 65000   	if hinctnta==9 & country==2&essround==9
replace income=	77450		if hinctnta==1 & country==3&essround==9
replace income=	176450.5	if hinctnta==2 & country==3&essround==9
replace income=	230700.5	if hinctnta==3 & country==3&essround==9
replace income=	285600.5  	if hinctnta==4 & country==3&essround==9
replace income=	334900.5 	if hinctnta==5 & country==3&essround==9
replace income=	393800.5 	if hinctnta==6 & country==3&essround==9
replace income=	464750.4  	if hinctnta==7 & country==3&essround==9
replace income=	547000.5 	if hinctnta==8 & country==3&essround==9 
replace income=	669600.5  	if hinctnta==9 & country==3&essround==9
replace income= 66000 		if hinctnta==1 & country==4&essround==9
replace income= 152999 		if hinctnta==2 & country==4&essround==9
replace income= 195499.5	if hinctnta==3 & country==4&essround==9
replace income= 240499.5 	if hinctnta==4 & country==4&essround==9
replace income= 294499.5 	if hinctnta==5 & country==4&essround==9
replace income= 361500  	if hinctnta==6 & country==4&essround==9
replace income= 429500  	if hinctnta==7 & country==4&essround==9
replace income= 497000  	if hinctnta==8 & country==4&essround==9
replace income= 581000  	if hinctnta==9 & country==4&essround==9
replace income=	2400		if hinctnta==1 & country==5&essround==9
replace income=	5406    	if hinctnta==2 & country==5&essround==9
replace income=	7506    	if hinctnta==3 & country==5&essround==9
replace income=	10326   	if hinctnta==4 & country==5&essround==9
replace income=	13620   	if hinctnta==5 & country==5&essround==9
replace income=	17406   	if hinctnta==6 & country==5&essround==9
replace income=	20406    	if hinctnta==7 & country==5&essround==9
replace income=	25206    	if hinctnta==8 & country==5&essround==9
replace income=	32406   	if hinctnta==9 & country==5&essround==9
replace income= 6942		if hinctnta==1 & country==6&essround==9
replace income= 15630    	if hinctnta==2 & country==6&essround==9
replace income= 19818   	if hinctnta==3 & country==6&essround==9 
replace income= 24732   	if hinctnta==4 & country==6&essround==9
replace income= 29904   	if hinctnta==5 & country==6&essround==9
replace income= 35928   	if hinctnta==6 & country==6&essround==9
replace income= 43188   	if hinctnta==7 & country==6&essround==9
replace income= 51450   	if hinctnta==8 & country==6&essround==9
replace income= 62778    	if hinctnta==9 & country==6&essround==9
replace income= 6650		if hinctnta==1 & country==7&essround==9 
replace income= 16550.5   	if hinctnta==2 & country==7&essround==9 
replace income= 21400.5  	if hinctnta==3 & country==7&essround==9 
replace income= 24850.5     if hinctnta==4 & country==7&essround==9 
replace income= 28650.5     if hinctnta==5 & country==7&essround==9 
replace income= 32750.5    	if hinctnta==6 & country==7&essround==9 
replace income= 37050.5 	if hinctnta==7 & country==7&essround==9 
replace income= 42000.5     if hinctnta==8 & country==7&essround==9 
replace income= 49450.5 	if hinctnta==9 & country==7&essround==9 
replace income= 7280		if hinctnta==1 & country==8&essround==9 
replace income= 17388   	if hinctnta==2 & country==8&essround==9 
replace income= 22708       if hinctnta==3 & country==8&essround==9 
replace income= 27748    	if hinctnta==4 & country==8&essround==9 
replace income= 32788   	if hinctnta==5 & country==8&essround==9 
replace income= 38388   	if hinctnta==6 & country==8&essround==9  
replace income= 45108   	if hinctnta==7 & country==8&essround==9 
replace income= 53228      	if hinctnta==8 & country==8&essround==9 
replace income= 65548   	if hinctnta==9 & country==8&essround==9 
replace income= 780000		if hinctnta==1 & country==10&essround==9 
replace income= 1794000  	if hinctnta==2 & country==10&essround==9 
replace income= 2208000 	if hinctnta==3 & country==10&essround==9 
replace income= 2394000 	if hinctnta==4 & country==10&essround==9 
replace income= 2928000 	if hinctnta==5 & country==10&essround==9 
replace income= 3294000 	if hinctnta==6 & country==10&essround==9 
replace income= 3654000 	if hinctnta==7 & country==10&essround==9 
replace income= 4074000 	if hinctnta==8 & country==10&essround==9 
replace income= 4614000 	if hinctnta==9 & country==10&essround==9 
replace income= 4500		if hinctnta==1 & country==19&essround==9 
replace income= 10506 	    if hinctnta==2 & country==19&essround==9 
replace income= 13806   	if hinctnta==3 & country==19&essround==9 
replace income= 17706   	if hinctnta==4 & country==19&essround==9 
replace income= 21906   	if hinctnta==5 & country==19&essround==9 
replace income= 26106   	if hinctnta==6 & country==19&essround==9 
replace income= 30906   	if hinctnta==7 & country==19&essround==9 
replace income= 37806   	if hinctnta==8 & country==19&essround==9 
replace income= 48606   	if hinctnta==9 & country==19&essround==9 
replace income= 6412		if hinctnta==1 & country==22&essround==9 
replace income= 15036  	    if hinctnta==2 & country==22&essround==9 
replace income= 19404   	if hinctnta==3 & country==22&essround==9 
replace income= 23912    	if hinctnta==4 & country==22&essround==9 
replace income= 28868   	if hinctnta==5 & country==22&essround==9 
replace income= 34412   	if hinctnta==6 & country==22&essround==9 
replace income= 40936    	if hinctnta==7 & country==22&essround==9 
replace income= 49768   	if hinctnta==8 & country==22&essround==9 
replace income= 62972   	if hinctnta==9 & country==22&essround==9 
replace income= 71994 		if hinctnta==1 & country==20&essround==9 
replace income= 167994	    if hinctnta==2 & country==20&essround==9 
replace income= 215994  	if hinctnta==3 & country==20&essround==9 
replace income= 273994  	if hinctnta==4 & country==20&essround==9 
replace income= 325994  	if hinctnta==5 & country==20&essround==9 
replace income= 407994   	if hinctnta==6 & country==20&essround==9 
replace income= 503994      if hinctnta==7 & country==20&essround==9 
replace income= 605994   	if hinctnta==8 & country==20&essround==9 
replace income= 749994  	if hinctnta==9 & country==20&essround==9 
replace income= 6500 		if hinctnta==1 & country==13&essround==9 
replace income= 15000   	if hinctnta==2 & country==13&essround==9  
replace income= 18500   	if hinctnta==3 & country==13&essround==9 
replace income= 22000   	if hinctnta==4 & country==13&essround==9  
replace income= 26000   	if hinctnta==5 & country==13&essround==9  
replace income= 30500   	if hinctnta==6 & country==13&essround==9 
replace income= 36000   	if hinctnta==7 & country==13&essround==9 
replace income= 42500   	if hinctnta==8 & country==13&essround==9 
replace income= 52000   	if hinctnta==9 & country==13&essround==9  
replace income= 7560 		if hinctnta==1 & country==11&essround==9 
replace income= 18340    	if hinctnta==2 & country==11&essround==9 
replace income= 25060   	if hinctnta==3 & country==11&essround==9 
replace income= 32060   	if hinctnta==4 & country==11&essround==9 
replace income= 39760   	if hinctnta==5 & country==11&essround==9 
replace income= 48020 	    if hinctnta==6 & country==11&essround==9 
replace income= 57260   	if hinctnta==7 & country==11&essround==9 
replace income= 68740 	    if hinctnta==8 & country==11&essround==9 
replace income= 84560   	if hinctnta==9 & country==11&essround==9 
replace income= 4500 		if hinctnta==1 & country==12&essround==9 
replace income= 11500    	if hinctnta==2 & country==12&essround==9 
replace income= 15750.5   	if hinctnta==3 & country==12&essround==9 
replace income= 19250.5  	if hinctnta==4 & country==12&essround==9 
replace income= 23000.5   	if hinctnta==5 & country==12&essround==9 
replace income= 27250.5  	if hinctnta==6 & country==12&essround==9 
replace income= 32750.5    	if hinctnta==7 & country==12&essround==9  
replace income= 39750.5 	if hinctnta==8 & country==12&essround==9 
replace income= 49750.5   	if hinctnta==9 & country==12&essround==9 
replace income=	2818		if hinctnta==1 & country==16&essround==9 
replace income=	6709 		if hinctnta==2 & country==16&essround==9 
replace income=	8847		if hinctnta==3 & country==16&essround==9 
replace income=	11264.5		if hinctnta==4 & country==16&essround==9 
replace income=	13884.5		if hinctnta==5 & country==16&essround==9 
replace income=	16556		if hinctnta==6 & country==16&essround==9  
replace income=	19727.5		if hinctnta==7 & country==16&essround==9 
replace income=	23947.5		if hinctnta==8 & country==16&essround==9  
replace income=	30746		if hinctnta==9 & country==16&essround==9 
replace income=	10200		if hinctnta==1 & country==15&essround==9 
replace income=	24006 		if hinctnta==2 & country==15&essround==9 
replace income=	31806		if hinctnta==3 & country==15&essround==9  
replace income=	39606		if hinctnta==4 & country==15&essround==9 
replace income=	47406		if hinctnta==5 & country==15&essround==9 
replace income=	55806		if hinctnta==6 & country==15&essround==9 
replace income=	65406		if hinctnta==7 & country==15&essround==9 
replace income=	77406		if hinctnta==8 & country==15&essround==9 
replace income=	94806		if hinctnta==9 & country==15&essround==9 
replace income=	3300		if hinctnta==1 & country==18&essround==9 
replace income=	8100 		if hinctnta==2 & country==18&essround==9
replace income=	10800		if hinctnta==3 & country==18&essround==9
replace income=	13800		if hinctnta==4 & country==18&essround==9
replace income=	17400		if hinctnta==5 & country==18&essround==9
replace income=	21000		if hinctnta==6 & country==18&essround==9 
replace income=	24600       if hinctnta==7 & country==18&essround==9
replace income=	28200		if hinctnta==8 & country==18&essround==9
replace income=	33600		if hinctnta==9 & country==18&essround==9 
replace income=	1620		if hinctnta==1 & country==17&essround==9
replace income=	4500 		if hinctnta==2 & country==17&essround==9
replace income=	6660		if hinctnta==3 & country==17&essround==9
replace income=	8580		if hinctnta==4 & country==17&essround==9
replace income=	10500		if hinctnta==5 & country==17&essround==9
replace income=	12300		if hinctnta==6 & country==17&essround==9
replace income=	14400		if hinctnta==7 & country==17&essround==9
replace income=	16800		if hinctnta==8 & country==17&essround==9
replace income=	19800		if hinctnta==9 & country==17&essround==9
replace	income=3000		    if hinctnta==1 & country==9&essround==9
replace	income=7200		    if hinctnta==2 & country==9&essround==9
replace	income=9600		    if hinctnta==3 & country==9&essround==9
replace	income=11880	    if hinctnta==4 & country==9&essround==9
replace	income=14280	    if hinctnta==5 & country==9&essround==9
replace	income=17160	    if hinctnta==6 & country==9&essround==9
replace	income=20760	    if hinctnta==7 & country==9&essround==9
replace	income=25200	    if hinctnta==8 & country==9&essround==9
replace	income=31800	    if hinctnta==9 & country==9&essround==9 
}


*/ non-Euro national currencies are converted into Euro
gen natincome=income

*/wave4
replace natincome=income/(4) if country == 15 & (essround==4)
replace natincome=income/(0.82) if country == 22 & (essround==4)
replace natincome=income/(300) if country == 10 & (essround==4)
replace natincome=income/(9.3) if country == 20 & (essround==4)
replace natincome=income/(7.5) if country == 4  & (essround==4)
replace natincome=income/(26.5) if country == 3  & (essround==4)
replace natincome=income/(15.6) if country == 5  & (essround==4)

*/wave5
replace natincome=income/(3.9) if country == 15 & (essround==5)
replace natincome=income/(0.82) if country == 22 & (essround==5)
replace natincome=income/(276.1) if country == 10 & (essround==5)
replace natincome=income/(9.3) if country == 20  & (essround==5)
replace natincome=income/(7.44) if country == 4  & (essround==5)
replace natincome=income/(24.2) if country == 3  & (essround==5)


*/wave6
replace natincome=income/(4.09) if country == 15 & (essround==6)
replace natincome=income*(1.24) if country == 22 & (essround==6)
replace natincome=income/(290) if country == 10 & (essround==6)
replace natincome=income*(0.117) if country == 20  & (essround==6)
replace natincome=income*(0.134) if country == 4  & (essround==6)
replace natincome=income/(25.6) if country == 3  & (essround==6)

*/wave7
replace natincome=income/(4.15) if country == 15 & (essround==7)
replace natincome=income*(1.36) if country == 22 & (essround==7)
replace natincome=income/(350) if country == 10 & (essround==7)
replace natincome=income*(0.11) if country == 20  & (essround==7)
replace natincome=income*(0.13) if country == 4  & (essround==7)
replace natincome=income/(27.8) if country == 3  & (essround==7)

*/wave8
replace natincome=income/(4.43) if country == 15 & (essround==8)
replace natincome=income*(1.18) if country == 22 & (essround==8)
replace natincome=income/(312) if country == 10 & (essround==8)
replace natincome=income*(0.10) if country == 20 & (essround==8)
replace natincome=income*(0.13) if country == 4  & (essround==8)
replace natincome=income/(27) if country == 3  & (essround==8)

*/wave9
replace natincome=income/(4.3) if country == 15 & (essround==9)
replace natincome=income*(1.12) if country == 22 & (essround==9)
replace natincome=income/(322) if country == 10 & (essround==9)
replace natincome=income/(10.17) if country == 20  & (essround==9)
replace natincome=income*(0.13) if country == 4  & (essround==9)
replace natincome=income/(25.7) if country == 3 & (essround==9)

*/ All income is put into 2010 Euro
gen natincome2010=natincome*100/CPI


// Income
recode hinctnta ///
	(1=1 "1st Decile") ///
	(2=2 "2nd Decile") ///
	(3=3 "3rd Decile") ///
	(4=4 "4th Decile") ///
	(5=5 "5th Decile") ///
	(6=6 "6th Decile") ///
	(7=7 "7th Decile") ///
	(8=8 "8th Decile") ///
	(9=9 "9th Decile") ///
	(10=10 "10th Decile") ///
	(else=.), gen(income2)
label variable income "Income by Decile"


********************************************************************
*********************** 6. Other variables *************************
********************************************************************

*/ Here I generate a number of other variables

*/6.1 Cooperative index
*/ Uses same method as Van Overbeke (2020)
sort country year
by country year: gen CI = (((Sectoral*50)+(RI*50)+(WC_RI*33)+(Coord*20)+(Coverage*0.25))/5)/100


*/6.2 Education
*/In theregressions we maximise educational years to 25 as in Rommel & Walter (2014) and Rueda & Theuwissen (2019)

*/next job = unify eduction
gen eduyrs2=eduyrs
	replace eduyrs2=. if inlist(eduyrs2,77,88,99)
	sum eduyrs2
	replace eduyrs2=25 if eduyrs2>25
	sum year if inlist(eduyrs2,11.5,14.5,18.5)
	replace eduyrs2=12 if eduyrs2==11.5
	replace eduyrs2=15 if eduyrs2==14.5
	replace eduyrs2=19 if eduyrs2==18.5
	label var eduyrs2 "eduyrs max 25, ref dont know no answer missing"
	

*/ISCED codes

gen degree=.
replace degree = 1 if  edulvla == 1
replace degree = 2 if  edulvla == 2
replace degree = 3 if  edulvla == 3
replace degree = 4 if  edulvla == 4
replace degree = 5 if  edulvla == 5

replace degree = 1 if edulvlb == 112 |  edulvlb == 129
replace degree = 2 if edulvlb == 213 |  edulvlb == 221  | edulvlb == 222 |  edulvlb == 223 
replace degree = 3 if edulvlb == 229 |  edulvlb == 311  | edulvlb == 312 |  edulvlb == 321 |  edulvlb == 323
replace degree = 4 if edulvlb == 412 |  edulvlb == 413  | edulvlb == 421 |  edulvlb == 422 |  edulvlb == 423
replace degree = 5 if edulvlb == 510 |  edulvlb == 520  | edulvlb == 610 |  edulvlb == 620 |  edulvlb == 710 | edulvlb == 720 |  edulvlb == 800


	
*/6.3 Church membership: I follow the literature and use rlgdgr
sum rlgblg  rlgdgr 
sum rlgblg if rlgblg<3
sum rlgdgr if rlgdgr<11

*/6.4 male dummy
gen male=1 if gndr==1
replace male=0 if gndr==2

*/6.5 Generate urban vs. rural dummy (not sure how exactly defined, but also done by Kitschelt & Rehm (2014) and Rommel and Walter (2014))
gen urban=1 if domicil<4
	replace urban=0 if inlist(domicil,4,5)
	label var urban "=1 if urban (domicil=1,2,3) ref dont know no answer missing"
	
*/6.6. Generate member trade union dummy: 1 if member or used to be member of trade union, 0 if not (3 used to be not member!)
gen mbtru2=.
	replace mbtru2=1 if inlist(mbtru,1,2)
	replace mbtru2=0 if mbtru==3
	label var mbtru2 "=1 if now or used to be trade union member (mbtru=1,2), 0 if not (mbtru=3), rest missing"
	

gen union =.
replace union =0 if mbtru ==3
replace union =1 if mbtru ==1
replace union =1 if mbtru ==2

*/6.7 Recoding agea
gen age = agea


*/6.8 sector

recode tporgwk ///
	(1 2 3=1 "Government and public sector") ///
	(4=2 "Private firm") ///
	(5=3 "Self employed") ///
	(else=.), ///
	gen(org_sec)

*/6.9 contract type
gen contract =.
replace contract = 0 if wrkctra ==3
replace contract = 1 if wrkctra ==1
replace contract = 1 if wrkctr ==1
replace contract = 2 if wrkctra ==2
replace contract = 2 if wrkctr ==2
label define contract 0 "No Contract" 1 "Temporary Contract" 2 "Permanent Contract"
label values contract contract
label var contract "type of contract"


gen Contract=.
replace Contract =0 if contract == 0
replace Contract =0 if contract == 2
replace Contract =1 if contract == 1
label define Contract 0 "Insecure" 1 "Permanent" 
label var Contract "type of contract"


*/6.10 exposure
gen exposure = computerisation*regexp2
gen exposure2 = RTI*regexp2

gen exposure3 = computerisation*regexp 
*/best one
gen exposure4 = RTI*regexp

*/6.11 retraining
gen retraining =.
replace retraining = 0 if atncrse == 2
replace retraining = 1 if atncrse == 1

*/6.11 miniroty
recode blgetmg ///
	(1=0 "Belong to ethnic minority") ///
	(2=1 "Do not belong to ethnic minority") ///
	(else=.), gen(ethnic_min)
	
*/6.12 growthrate
bys region: gen realgrowthrate = (n2_mio_pps_[_n]-n2_mio_pps_[_n-1])/n2_mio_pps_[_n-1]
bys region: gen realgrowthrate2 = (GDPcurrentprice[_n]-GDPcurrentprice[_n-1])/GDPcurrentprice[_n-1]
bys region: gen realgrowthrate3 = (GDPCap[_n]-GDPCap[_n-1])/GDPCap[_n-1]
bys region: gen realgrowthrate4 = (n2_mio_pps_-n2_mio_pps_[_n-1])/n2_mio_pps_[_n-1]

*/6.13 lshare
gen lshare = Totalcompensation/GDPcurrentprice
drop if lshare <0.3

*/6.14 Dummy whether someone is unemployed, or in the labour force
gen unemplindiv=0
	replace unemplindiv=1 if inlist(mnactic,3)
	label var unemplindiv "=1 if mnactic==3"


*/6.15 group by model

gen model =.
replace model = 1 if country ==1 
replace model = 1 if country ==2 
replace model = 1 if country ==8 
replace model = 1 if country ==13 
replace model = 2 if country ==4
replace model = 2 if country ==19
replace model = 2 if country ==6
replace model = 3 if country ==3
replace model = 3 if country ==5
replace model = 3 if country ==10
replace model = 3 if country ==14
replace model = 3 if country ==16
replace model = 3 if country ==17
replace model = 4 if country ==7
replace model = 4 if country ==9
replace model = 4 if country ==12
replace model = 4 if country ==15
replace model = 4 if country ==18
replace model = 5 if country ==11
replace model = 5 if country ==20

label define model  1 "Coordinated" 2 "Scandinavian" 3 "CEE" 4 "Southern" 5 "Liberal"
label value model model

*/6.16 election dummy 
egen electiondum = group(country election)


*/6.17  presence of far right
gen rightpres = 1
replace rightpres = 0 if country == 11
replace rightpres = 0 if country == 15
replace rightpres = 0 if country == 18 & year <2018

*/6.18 fiscal Spending rolling average
asrol deficit, stat(mean) win(year 4) gen(deficit4) 
asrol diffdebt, stat(mean) win(year 4) gen(difdebt4) 

gen mainsample=1 if  computerisation~=. &  ///
	eduyrs2~=. & male~=. & agea~=. &  rlgdgr~=. & unemplindiv~=. & ///
	age<124 & rlgdgr<11 & inlist(mnactic,1,3) & pdwrk == 1 & year > 2010





********************************************************************
*********************** 7. Saving dataset *************************
********************************************************************

save "Final", replace


